(t *testing.T)
| 12 | ) |
| 13 | |
| 14 | func TestJSONRPCSSE(t *testing.T) { |
| 15 | cases := []struct { |
| 16 | Name string |
| 17 | DSL func() |
| 18 | }{ |
| 19 | {"string", testdata.JSONRPCSSEStringDSL}, |
| 20 | {"object", testdata.JSONRPCSSEObjectDSL}, |
| 21 | } |
| 22 | |
| 23 | for _, c := range cases { |
| 24 | t.Run(c.Name, func(t *testing.T) { |
| 25 | root := RunJSONRPCDSL(t, c.DSL) |
| 26 | services := CreateJSONRPCServices(root) |
| 27 | |
| 28 | // Generate SSE files |
| 29 | fs := SSEServerFiles("", services) |
| 30 | require.NotEmpty(t, fs, "expected SSE files to be generated") |
| 31 | |
| 32 | // Debug: print all generated files |
| 33 | for _, f := range fs { |
| 34 | t.Logf("Generated file: %s", f.Path) |
| 35 | } |
| 36 | |
| 37 | // Find the server stream file |
| 38 | var serverStreamFile *codegen.File |
| 39 | for _, f := range fs { |
| 40 | if filepath.Base(f.Path) == "stream.go" && filepath.Base(filepath.Dir(f.Path)) == "server" { |
| 41 | serverStreamFile = f |
| 42 | break |
| 43 | } |
| 44 | } |
| 45 | require.NotNil(t, serverStreamFile, "server stream file not found") |
| 46 | |
| 47 | // Find the jsonrpc-sse-server-stream section |
| 48 | var streamSection *codegen.SectionTemplate |
| 49 | for _, s := range serverStreamFile.SectionTemplates { |
| 50 | if s.Name == "jsonrpc-sse-server-stream" { |
| 51 | streamSection = s |
| 52 | break |
| 53 | } |
| 54 | } |
| 55 | require.NotNil(t, streamSection, "jsonrpc-sse-server-stream section not found") |
| 56 | |
| 57 | // Compare with golden file |
| 58 | code := codegen.SectionCode(t, streamSection) |
| 59 | golden := filepath.Join("testdata", "golden", "jsonrpc-sse-"+c.Name+".golden") |
| 60 | testutil.CompareOrUpdateGolden(t, code, golden) |
| 61 | }) |
| 62 | } |
| 63 | } |
nothing calls this directly
no test coverage detected