Skip to content

Commit

Permalink
bonsai
Browse files Browse the repository at this point in the history
  • Loading branch information
k1LoW committed Nov 18, 2018
1 parent f534ddb commit 70af482
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
30 changes: 12 additions & 18 deletions schema/schema_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package schema

import (
"os"
"path/filepath"
"testing"
)

Expand Down Expand Up @@ -123,24 +125,10 @@ func TestAddAditionalData(t *testing.T) {
},
},
}
additionalBytes := []byte(`
---
relations:
-
table: posts
columns:
- user_id
parentTable: users
parentColumns:
- id
def: posts->users
comments:
-
table: posts
columnComments:
title: post title
`)
_ = schema.AddAdditionalData(additionalBytes)
err := schema.LoadAdditionalData(filepath.Join(testdataDir(), "schema_test_additional_data.yml"))
if err != nil {
t.Error(err)
}
expected := 1
actual := len(schema.Relations)
if actual != expected {
Expand All @@ -154,3 +142,9 @@ comments:
t.Errorf("actual %v\nwant %v", actual2, expected2)
}
}

func testdataDir() string {
wd, _ := os.Getwd()
dir, _ := filepath.Abs(filepath.Join(filepath.Dir(wd), "testdata"))
return dir
}
15 changes: 15 additions & 0 deletions testdata/schema_test_additional_data.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
relations:
-
table: posts
columns:
- user_id
parentTable: users
parentColumns:
- id
def: posts->users
comments:
-
table: posts
columnComments:
title: post title

0 comments on commit 70af482

Please sign in to comment.