| 198 | } |
| 199 | |
| 200 | func (ContainerSuite) TestError(ctx context.Context, t *testctx.T) { |
| 201 | for _, tc := range []struct { |
| 202 | name string |
| 203 | query string |
| 204 | expectedErr *string |
| 205 | }{ |
| 206 | { |
| 207 | "with error message", |
| 208 | ` |
| 209 | { |
| 210 | container { |
| 211 | from(address: "` + alpineImage + `") { |
| 212 | withError(err: "error raised") { |
| 213 | sync |
| 214 | } |
| 215 | } |
| 216 | } |
| 217 | }`, |
| 218 | ptr("error raised"), |
| 219 | }, |
| 220 | { |
| 221 | "with empty error message", |
| 222 | ` |
| 223 | { |
| 224 | container { |
| 225 | from(address: "` + alpineImage + `") { |
| 226 | withError(err: "") { |
| 227 | sync |
| 228 | } |
| 229 | } |
| 230 | } |
| 231 | }`, |
| 232 | nil, |
| 233 | }, |
| 234 | } { |
| 235 | t.Run(tc.name, func(ctx context.Context, t *testctx.T) { |
| 236 | _, err := testutil.Query[struct { |
| 237 | Container struct { |
| 238 | From struct { |
| 239 | WithError struct { |
| 240 | Sync string |
| 241 | } |
| 242 | } |
| 243 | } |
| 244 | }](t, tc.query, nil) |
| 245 | if tc.expectedErr == nil { |
| 246 | require.NoError(t, err) |
| 247 | } else { |
| 248 | require.ErrorContains(t, err, *tc.expectedErr) |
| 249 | } |
| 250 | }) |
| 251 | } |
| 252 | } |
| 253 | |
| 254 | func (ContainerSuite) TestExecStdoutStderr(ctx context.Context, t *testctx.T) { |
| 255 | c := connect(ctx, t) |