RunDSL returns the DSL root resulting from running the given DSL.
(t *testing.T, dsl func())
| 14 | |
| 15 | // RunDSL returns the DSL root resulting from running the given DSL. |
| 16 | func RunDSL(t *testing.T, dsl func()) *expr.RootExpr { |
| 17 | t.Helper() |
| 18 | eval.Reset() |
| 19 | expr.Root = new(expr.RootExpr) |
| 20 | expr.GeneratedResultTypes = new(expr.ResultTypesRoot) |
| 21 | require.NoError(t, eval.Register(expr.Root)) |
| 22 | require.NoError(t, eval.Register(expr.GeneratedResultTypes)) |
| 23 | expr.Root.API = expr.NewAPIExpr("test api", func() {}) |
| 24 | expr.Root.API.Servers = []*expr.ServerExpr{expr.Root.API.DefaultServer()} |
| 25 | require.True(t, eval.Execute(dsl, nil), eval.Context.Error()) |
| 26 | require.NoError(t, eval.RunDSL()) |
| 27 | return expr.Root |
| 28 | } |
| 29 | |
| 30 | // SectionCode generates and formats the code for the given section. |
| 31 | func SectionCode(t *testing.T, section *SectionTemplate) string { |