From 7dc7301239bf146368b57dadfd905d327199b3ad Mon Sep 17 00:00:00 2001 From: k1LoW Date: Sun, 8 Oct 2023 10:11:11 +0900 Subject: [PATCH] bonsai --- config/config.go | 6 ++---- config/config_test.go | 21 ++++++++++++++------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/config/config.go b/config/config.go index 545310c0..da405cad 100644 --- a/config/config.go +++ b/config/config.go @@ -512,12 +512,10 @@ func (c *Config) ModifySchema(s *schema.Schema) error { // MergeAdditionalData merge relations: comments: to schema.Schema func (c *Config) MergeAdditionalData(s *schema.Schema) error { - err := mergeAdditionalRelations(s, c.Relations) - if err != nil { + if err := mergeAdditionalRelations(s, c.Relations); err != nil { return err } - err = mergeAdditionalComments(s, c.Comments) - if err != nil { + if err := mergeAdditionalComments(s, c.Comments); err != nil { return err } return nil diff --git a/config/config_test.go b/config/config_test.go index a6c29303..cd5328fc 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -132,20 +132,27 @@ func TestMergeAditionalData(t *testing.T) { if err != nil { t.Error(err) } - err = c.LoadConfigFile(filepath.Join(testdataDir(), "config_test_tbls.yml")) - if err != nil { + if err := c.LoadConfigFile(filepath.Join(testdataDir(), "config_test_tbls.yml")); err != nil { t.Error(err) } - err = c.MergeAdditionalData(&s) - if err != nil { + if err := c.MergeAdditionalData(&s); err != nil { t.Error(err) } if want := 1; len(s.Relations) != want { t.Errorf("got %v\nwant %v", len(s.Relations), want) } - users, _ := s.FindTableByName("users") - posts, _ := s.FindTableByName("posts") - title, _ := posts.FindColumnByName("title") + users, err := s.FindTableByName("users") + if err != nil { + t.Fatal(err) + } + posts, err := s.FindTableByName("posts") + if err != nil { + t.Fatal(err) + } + title, err := posts.FindColumnByName("title") + if err != nil { + t.Fatal(err) + } if want := "post title"; title.Comment != want { t.Errorf("got %v\nwant %v", title.Comment, want) }