(t *testing.T)
| 12 | ) |
| 13 | |
| 14 | func TestExampleServiceFiles(t *testing.T) { |
| 15 | t.Run("package name check", func(t *testing.T) { |
| 16 | cases := []struct { |
| 17 | Name string |
| 18 | DSL func() |
| 19 | Expected string |
| 20 | }{ |
| 21 | { |
| 22 | Name: "conflict with API name and service names", |
| 23 | DSL: testdata.ConflictWithAPINameAndServiceNameDSL, |
| 24 | Expected: "package alohaapi2", |
| 25 | }, |
| 26 | { |
| 27 | Name: "conflict with goified API name and goified service names", |
| 28 | DSL: testdata.ConflictWithGoifiedAPINameAndServiceNamesDSL, |
| 29 | Expected: "package goodbyapi2", |
| 30 | }, |
| 31 | } |
| 32 | for _, c := range cases { |
| 33 | t.Run(c.Name, func(t *testing.T) { |
| 34 | root := codegen.RunDSL(t, c.DSL) |
| 35 | services := NewServicesData(root) |
| 36 | require.Len(t, root.Services, 3) |
| 37 | fs := ExampleServiceFiles("", root, services) |
| 38 | require.Len(t, fs, 3) |
| 39 | for _, f := range fs { |
| 40 | require.Greater(t, len(f.SectionTemplates), 0) |
| 41 | var b bytes.Buffer |
| 42 | require.NoError(t, f.SectionTemplates[0].Write(&b)) |
| 43 | line, err := b.ReadBytes('\n') |
| 44 | require.NoError(t, err) |
| 45 | got := string(bytes.TrimRight(line, "\r\n")) |
| 46 | assert.Equal(t, c.Expected, got) |
| 47 | } |
| 48 | }) |
| 49 | } |
| 50 | }) |
| 51 | } |
nothing calls this directly
no test coverage detected