From 70af482e3d16b3f2be070b932849b51745d69792 Mon Sep 17 00:00:00 2001 From: k1LoW Date: Sun, 18 Nov 2018 16:45:59 +0900 Subject: [PATCH] bonsai --- schema/schema_test.go | 30 ++++++++++-------------- testdata/schema_test_additional_data.yml | 15 ++++++++++++ 2 files changed, 27 insertions(+), 18 deletions(-) create mode 100644 testdata/schema_test_additional_data.yml diff --git a/schema/schema_test.go b/schema/schema_test.go index b9311848..5ab00f8d 100644 --- a/schema/schema_test.go +++ b/schema/schema_test.go @@ -1,6 +1,8 @@ package schema import ( + "os" + "path/filepath" "testing" ) @@ -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 { @@ -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 +} diff --git a/testdata/schema_test_additional_data.yml b/testdata/schema_test_additional_data.yml new file mode 100644 index 00000000..b477a377 --- /dev/null +++ b/testdata/schema_test_additional_data.yml @@ -0,0 +1,15 @@ +--- +relations: + - + table: posts + columns: + - user_id + parentTable: users + parentColumns: + - id + def: posts->users +comments: + - + table: posts + columnComments: + title: post title