TestWebSocketGoldenFiles tests WebSocket code generation against golden files to ensure comprehensive coverage of all WebSocket templates and scenarios.
(t *testing.T)
| 27 | // TestWebSocketGoldenFiles tests WebSocket code generation against golden files |
| 28 | // to ensure comprehensive coverage of all WebSocket templates and scenarios. |
| 29 | func TestWebSocketGoldenFiles(t *testing.T) { |
| 30 | cases := []struct { |
| 31 | name string |
| 32 | dsl func() |
| 33 | fileType string // "server" or "client" |
| 34 | }{ |
| 35 | // Server Streaming (Result only) |
| 36 | {"websocket-server-streaming-primitive", serverStreamingPrimitiveDSL, "server"}, |
| 37 | {"websocket-server-streaming-array", serverStreamingArrayDSL, "server"}, |
| 38 | {"websocket-server-streaming-object", serverStreamingObjectDSL, "server"}, |
| 39 | {"websocket-server-streaming-user-type", serverStreamingUserTypeDSL, "server"}, |
| 40 | {"websocket-server-streaming-with-views", serverStreamingWithViewsDSL, "server"}, |
| 41 | |
| 42 | // Client Streaming (Payload only) |
| 43 | {"websocket-client-streaming-primitive", clientStreamingPrimitiveDSL, "client"}, |
| 44 | {"websocket-client-streaming-array", clientStreamingArrayDSL, "client"}, |
| 45 | {"websocket-client-streaming-object", clientStreamingObjectDSL, "client"}, |
| 46 | {"websocket-client-streaming-user-type", clientStreamingUserTypeDSL, "client"}, |
| 47 | {"websocket-client-streaming-with-validation", clientStreamingWithValidationDSL, "client"}, |
| 48 | |
| 49 | // Bidirectional Streaming |
| 50 | {"websocket-bidirectional-streaming-primitive", bidirectionalStreamingPrimitiveDSL, "server"}, |
| 51 | {"websocket-bidirectional-streaming-complex", bidirectionalStreamingComplexDSL, "server"}, |
| 52 | {"websocket-bidirectional-streaming-with-views", bidirectionalStreamingWithViewsDSL, "server"}, |
| 53 | |
| 54 | // Client-side Bidirectional |
| 55 | {"websocket-bidirectional-streaming-primitive-client", bidirectionalStreamingPrimitiveDSL, "client"}, |
| 56 | {"websocket-bidirectional-streaming-complex-client", bidirectionalStreamingComplexDSL, "client"}, |
| 57 | {"websocket-bidirectional-streaming-with-views-client", bidirectionalStreamingWithViewsDSL, "client"}, |
| 58 | |
| 59 | // Edge Cases |
| 60 | {"websocket-no-payload-streaming", noPayloadStreamingDSL, "server"}, |
| 61 | {"websocket-no-result-streaming", noResultStreamingDSL, "server"}, |
| 62 | {"websocket-mixed-endpoints", mixedEndpointsDSL, "server"}, |
| 63 | {"websocket-mixed-endpoints-client", mixedEndpointsDSL, "client"}, |
| 64 | |
| 65 | // Template Coverage Tests |
| 66 | {"websocket-conn-configurer", connConfigurerDSL, "server"}, |
| 67 | {"websocket-conn-configurer-client", connConfigurerDSL, "client"}, |
| 68 | {"websocket-struct-types", structTypesDSL, "server"}, |
| 69 | {"websocket-struct-types-client", structTypesDSL, "client"}, |
| 70 | } |
| 71 | |
| 72 | for _, c := range cases { |
| 73 | t.Run(c.name, func(t *testing.T) { |
| 74 | root := RunHTTPDSL(t, c.dsl) |
| 75 | services := CreateHTTPServices(root) |
| 76 | |
| 77 | var files []*codegen.File |
| 78 | if c.fileType == "server" { |
| 79 | files = ServerFiles("", services) |
| 80 | } else { |
| 81 | files = ClientFiles("", services) |
| 82 | } |
| 83 | |
| 84 | // Find the websocket.go file |
| 85 | var wsFile *codegen.File |
| 86 | for _, f := range files { |
nothing calls this directly
no test coverage detected