Skip to content

Commit

Permalink
add unit test for list of enums
Browse files Browse the repository at this point in the history
  • Loading branch information
nicovogelaar committed Jan 4, 2019
1 parent 1e3e5e9 commit 1140dd8
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions codegen/codegen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ func TestGenerateServer(t *testing.T) {
id: Int
fist_name: String
}
enum Status {
OK
ERROR
}
`
serverFilename := "gen/" + name + "/server/server.go"
cfg := Config{
Expand All @@ -42,4 +46,30 @@ func TestGenerateServer(t *testing.T) {

_, err = conf.Load()
require.NoError(t, err)

t.Run("list of enums", func(t *testing.T) {
conf = loader.Config{}
conf.CreateFromFilenames("gen/"+name, "gen/"+name+"/model.go")

program, err := conf.Load()
require.NoError(t, err)

found := false

for _, c := range program.Created {
for ident := range c.Defs {
if ident.Name == "AllStatus" {
found = true
break
}
}
if found {
break
}
}

if !found {
t.Fail()
}
})
}

0 comments on commit 1140dd8

Please sign in to comment.