From 1140dd85782572b148e8ec2c1d9526f87b763a1e Mon Sep 17 00:00:00 2001 From: Nico Vogelaar Date: Fri, 4 Jan 2019 19:43:38 +0000 Subject: [PATCH] add unit test for list of enums --- codegen/codegen_test.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/codegen/codegen_test.go b/codegen/codegen_test.go index ebe1bf16418..7135f996ac0 100644 --- a/codegen/codegen_test.go +++ b/codegen/codegen_test.go @@ -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{ @@ -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() + } + }) }