MCPcopy Create free account
hub / github.com/goadesign/goa / TestStreamingErrorsWithValidation

Function TestStreamingErrorsWithValidation

grpc/codegen/streaming_errors_test.go:85–113  ·  view source on GitHub ↗

TestStreamingErrorsWithValidation verifies that custom errors with validation rules are properly validated in streaming recv methods.

(t *testing.T)

Source from the content-addressed store, hash-verified

83// TestStreamingErrorsWithValidation verifies that custom errors with
84// validation rules are properly validated in streaming recv methods.
85func TestStreamingErrorsWithValidation(t *testing.T) {
86 root := RunGRPCDSL(t, testdata.ServerStreamingWithCustomErrorsDSL)
87 services := CreateGRPCServices(root)
88
89 // Verify the DSL has errors with validation
90 require.Len(t, root.Services, 1)
91 svc := root.Services[0]
92 require.Len(t, svc.Methods, 1)
93 method := svc.Methods[0]
94 require.Greater(t, len(method.Errors), 0, "method should have errors defined")
95
96 // Generate client code
97 clientfs := ClientFiles("", services)
98 require.Greater(t, len(clientfs), 0)
99
100 // Check recv implementations
101 recvSections := clientfs[0].Section("client-stream-recv")
102 var code strings.Builder
103 for _, section := range recvSections {
104 require.NoError(t, section.Write(&code))
105 }
106 recvCode := code.String()
107
108 // For errors with validation, verify validation is called
109 if strings.Contains(recvCode, "ValidateServerStreamCustomErrorError") {
110 assert.Contains(t, recvCode, "if err := ValidateServerStreamCustomErrorError(message); err != nil {",
111 "should validate custom error before returning")
112 }
113}
114
115// TestStreamingErrorComparison compares error handling between unary and
116// streaming methods to ensure consistency.

Callers

nothing calls this directly

Calls 6

RunGRPCDSLFunction · 0.85
CreateGRPCServicesFunction · 0.85
SectionMethod · 0.80
ClientFilesFunction · 0.70
StringMethod · 0.65
WriteMethod · 0.45

Tested by

no test coverage detected