initDSL initializes the DSL environment and returns the root.
(t *testing.T)
| 11 | |
| 12 | // initDSL initializes the DSL environment and returns the root. |
| 13 | func initDSL(t *testing.T) *expr.RootExpr { |
| 14 | // reset all roots and codegen data structures |
| 15 | eval.Reset() |
| 16 | expr.Root = new(expr.RootExpr) |
| 17 | expr.GeneratedResultTypes = new(expr.ResultTypesRoot) |
| 18 | expr.Root.API = expr.NewAPIExpr("test api", func() {}) |
| 19 | expr.Root.API.Servers = []*expr.ServerExpr{expr.Root.API.DefaultServer()} |
| 20 | root := expr.Root |
| 21 | require.NoError(t, eval.Register(root)) |
| 22 | require.NoError(t, eval.Register(expr.GeneratedResultTypes)) |
| 23 | return root |
| 24 | } |
| 25 | |
| 26 | // runDSL returns the DSL root resulting from running the given DSL. |
| 27 | func runDSL(t *testing.T, dsl func()) *expr.RootExpr { |
no test coverage detected