@@ -105,6 +105,8 @@ func TestEchoPartialError_ReturnsMixedResults(t *testing.T) {
105105 }
106106 if resp .EchoPartialError [1 ].Error == nil {
107107 t .Error ("expected second error to be non-nil" )
108+ } else if * resp .EchoPartialError [1 ].Error != "message contains 'error'" {
109+ t .Errorf ("expected error message 'message contains 'error'', got %q" , * resp .EchoPartialError [1 ].Error )
108110 }
109111
110112 // Third result: "world" - should have message, no error
@@ -116,6 +118,59 @@ func TestEchoPartialError_ReturnsMixedResults(t *testing.T) {
116118 }
117119}
118120
121+ func TestEchoPartialError_ContainsErrorSubstring (t * testing.T ) {
122+ c := setupTestClient (t )
123+
124+ testCases := []struct {
125+ input string
126+ shouldError bool
127+ }{
128+ {"success" , false },
129+ {"error" , true },
130+ {"ERROR" , true },
131+ {"this is an error message" , true },
132+ {"errorHandling" , true },
133+ {"no problem here" , false },
134+ {"Error: something went wrong" , true },
135+ }
136+
137+ for _ , tc := range testCases {
138+ t .Run (tc .input , func (t * testing.T ) {
139+ var resp struct {
140+ EchoPartialError []struct {
141+ Message * string
142+ Error * string
143+ }
144+ }
145+ query := `query { echoPartialError(messages: ["` + tc .input + `"]) { message error } }`
146+ c .MustPost (query , & resp )
147+
148+ if len (resp .EchoPartialError ) != 1 {
149+ t .Fatalf ("expected 1 result, got %d" , len (resp .EchoPartialError ))
150+ }
151+
152+ result := resp .EchoPartialError [0 ]
153+ if tc .shouldError {
154+ if result .Message != nil {
155+ t .Errorf ("expected message to be nil for %q, got %v" , tc .input , * result .Message )
156+ }
157+ if result .Error == nil {
158+ t .Errorf ("expected error to be non-nil for %q" , tc .input )
159+ } else if * result .Error != "message contains 'error'" {
160+ t .Errorf ("expected error message 'message contains 'error'', got %q" , * result .Error )
161+ }
162+ } else {
163+ if result .Message == nil || * result .Message != tc .input {
164+ t .Errorf ("expected message to be %q, got %v" , tc .input , result .Message )
165+ }
166+ if result .Error != nil {
167+ t .Errorf ("expected error to be nil for %q, got %v" , tc .input , * result .Error )
168+ }
169+ }
170+ })
171+ }
172+ }
173+
119174func TestEchoWithExtensions_ReturnsMessage (t * testing.T ) {
120175 c := setupTestClient (t )
121176
0 commit comments