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

Function TestValidateMountsSyntax

pkg/workflow/sandbox_mounts_test.go:11–108  ·  view source on GitHub ↗

TestValidateMountsSyntax tests the mount syntax validation function

(t *testing.T)

Source from the content-addressed store, hash-verified

9
10// TestValidateMountsSyntax tests the mount syntax validation function
11func TestValidateMountsSyntax(t *testing.T) {
12 tests := []struct {
13 name string
14 mounts []string
15 wantErr bool
16 errMsg string
17 }{
18 {
19 name: "valid read-only mount",
20 mounts: []string{"/host/path:/container/path:ro"},
21 wantErr: false,
22 },
23 {
24 name: "valid read-write mount",
25 mounts: []string{"/host/path:/container/path:rw"},
26 wantErr: false,
27 },
28 {
29 name: "multiple valid mounts",
30 mounts: []string{
31 "/host/data:/data:ro",
32 "/usr/local/bin/tool:/usr/local/bin/tool:ro",
33 "/tmp/cache:/cache:rw",
34 },
35 wantErr: false,
36 },
37 {
38 name: "empty mounts list",
39 mounts: []string{},
40 wantErr: false,
41 },
42 {
43 name: "invalid mount - too few parts",
44 mounts: []string{"/host/path:/container/path"},
45 wantErr: true,
46 errMsg: "mount syntax must follow 'source:destination:mode' format",
47 },
48 {
49 name: "invalid mount - too many parts",
50 mounts: []string{"/host/path:/container/path:ro:extra"},
51 wantErr: true,
52 errMsg: "mount syntax must follow 'source:destination:mode' format",
53 },
54 {
55 name: "invalid mount - empty source",
56 mounts: []string{":/container/path:ro"},
57 wantErr: true,
58 errMsg: "source path cannot be empty",
59 },
60 {
61 name: "invalid mount - empty destination",
62 mounts: []string{"/host/path::ro"},
63 wantErr: true,
64 errMsg: "destination path cannot be empty",
65 },
66 {
67 name: "invalid mount - invalid mode",
68 mounts: []string{"/host/path:/container/path:xyz"},

Callers

nothing calls this directly

Calls 4

validateMountsSyntaxFunction · 0.85
RunMethod · 0.45
ErrorfMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected