Skip to content

Commit

Permalink
bonsai
Browse files Browse the repository at this point in the history
  • Loading branch information
k1LoW committed Oct 8, 2023
1 parent ca6a902 commit 7dc7301
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
6 changes: 2 additions & 4 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 14 additions & 7 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 7dc7301

Please sign in to comment.