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 1710290 commit 210eede
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 210eede

Please sign in to comment.