Skip to content

Commit

Permalink
Merge pull request #292 from trico/string_model
Browse files Browse the repository at this point in the history
Fix generate fields count report
  • Loading branch information
mcuadros authored Mar 20, 2019
2 parents a7b3dba + 12b6fe5 commit 0f81f1a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion generator/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ func (m *Model) String() string {
events = append(events, string(e))
}

return fmt.Sprintf("%q [%d Field(s)] [Events: %s]", m.Name, len(m.Fields), events)
return fmt.Sprintf("%q [%d Field(s)] [Events: %s]", m.Name, len(m.Fields)-1, events)
}

type occurrences map[string]uint
Expand Down
5 changes: 5 additions & 0 deletions generator/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,11 @@ func (s *ModelSuite) TestModelValidate() {
require.Error(m.Validate(), "should return error")
}

func (s *ModelSuite) TestString() {
s.Equal("\"Variadic\" [3 Field(s)] [Events: []]", s.variadic.String())
s.Equal("\"User\" [7 Field(s)] [Events: []]", s.model.String())
}

func TestFieldForeignKey(t *testing.T) {
r := require.New(t)
m := &Model{Name: "Foo", Table: "bar", Type: "foo.Foo"}
Expand Down

0 comments on commit 0f81f1a

Please sign in to comment.