MCPcopy Create free account
hub / github.com/github/gh-aw / TestValidateMountStringFormat

Function TestValidateMountStringFormat

pkg/workflow/validation_helpers_test.go:346–423  ·  view source on GitHub ↗

TestValidateMountStringFormat tests the shared mount format validation primitive.

(t *testing.T)

Source from the content-addressed store, hash-verified

344
345// TestValidateMountStringFormat tests the shared mount format validation primitive.
346func TestValidateMountStringFormat(t *testing.T) {
347 tests := []struct {
348 name string
349 mount string
350 wantErr bool
351 wantSrc string
352 wantDest string
353 wantMode string
354 allEmpty bool // true when format error (all three return values are empty)
355 }{
356 {
357 name: "valid ro mount",
358 mount: "/host/data:/data:ro",
359 wantSrc: "/host/data",
360 wantDest: "/data",
361 wantMode: "ro",
362 },
363 {
364 name: "valid rw mount",
365 mount: "/host/data:/data:rw",
366 wantSrc: "/host/data",
367 wantDest: "/data",
368 wantMode: "rw",
369 },
370 {
371 name: "too few parts — format error, all values empty",
372 mount: "/host/path:/container/path",
373 wantErr: true,
374 allEmpty: true,
375 },
376 {
377 name: "too many parts — format error, all values empty",
378 mount: "/host/path:/container/path:ro:extra",
379 wantErr: true,
380 allEmpty: true,
381 },
382 {
383 name: "invalid mode — source and dest returned, mode returned",
384 mount: "/host/path:/container/path:xyz",
385 wantErr: true,
386 wantSrc: "/host/path",
387 wantDest: "/container/path",
388 wantMode: "xyz",
389 },
390 {
391 name: "empty mode — source and dest returned, mode empty string",
392 mount: "/host/path:/container/path:",
393 wantErr: true,
394 wantSrc: "/host/path",
395 wantDest: "/container/path",
396 wantMode: "",
397 },
398 }
399
400 for _, tt := range tests {
401 t.Run(tt.name, func(t *testing.T) {
402 src, dest, mode, err := validateMountStringFormat(tt.mount)
403

Callers

nothing calls this directly

Calls 3

RunMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected