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

Function TestIsValidCacheID

pkg/workflow/cache_id_validation_test.go:13–48  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func TestIsValidCacheID(t *testing.T) {
14 tests := []struct {
15 name string
16 id string
17 valid bool
18 }{
19 // Valid IDs
20 {"simple word", "default", true},
21 {"plain word", "session", true},
22 {"with hyphen", "my-cache", true},
23 {"with underscore", "my_cache", true},
24 {"alphanumeric", "cache123", true},
25 {"mixed", "A1-b2_C3", true},
26 {"exactly 64 chars", strings.Repeat("a", 64), true},
27
28 // Invalid IDs
29 {"empty string", "", false},
30 {"65 chars", strings.Repeat("a", 65), false},
31 {"path traversal dot-dot-slash", "../etc", false},
32 {"path traversal nested", "../../etc/passwd", false},
33 {"forward slash", "cache/sub", false},
34 {"backslash", `cache\sub`, false},
35 {"dot separator", "cache.mem", false},
36 {"space", "cache mem", false},
37 {"colon", "cache:mem", false},
38 {"wildcard asterisk", "cache*", false},
39 {"question mark", "cache?", false},
40 {"angle brackets", "cache<mem>", false},
41 }
42
43 for _, tt := range tests {
44 t.Run(tt.name, func(t *testing.T) {
45 assert.Equal(t, tt.valid, isValidCacheID(tt.id), "isValidCacheID(%q)", tt.id)
46 })
47 }
48}
49
50func TestParseCacheMemoryEntry_InvalidID(t *testing.T) {
51 compiler := NewCompiler()

Callers

nothing calls this directly

Calls 2

isValidCacheIDFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected