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

Function TestCacheMemoryStepsIncludeGitSetup

pkg/workflow/cache_integrity_test.go:382–418  ·  view source on GitHub ↗

TestCacheMemoryStepsIncludeGitSetup verifies that generated workflow YAML includes the git setup step after the cache restore step.

(t *testing.T)

Source from the content-addressed store, hash-verified

380// TestCacheMemoryStepsIncludeGitSetup verifies that generated workflow YAML includes
381// the git setup step after the cache restore step.
382func TestCacheMemoryStepsIncludeGitSetup(t *testing.T) {
383 toolsMap := map[string]any{
384 "cache-memory": true,
385 "github": map[string]any{
386 "allowed": []any{"get_repository"},
387 "min-integrity": "unapproved",
388 "allowed-repos": []any{"github/gh-aw"},
389 },
390 }
391
392 toolsConfig, err := ParseToolsConfig(toolsMap)
393 require.NoError(t, err, "Should parse tools config")
394
395 compiler := NewCompiler()
396 cacheMemoryConfig, err := compiler.extractCacheMemoryConfig(toolsConfig)
397 require.NoError(t, err, "Should extract cache-memory config")
398
399 parsedTools := NewTools(toolsMap)
400
401 data := &WorkflowData{
402 CacheMemoryConfig: cacheMemoryConfig,
403 ParsedTools: parsedTools,
404 }
405
406 var builder strings.Builder
407 generateCacheMemorySteps(&builder, data)
408 output := builder.String()
409
410 assert.Contains(t, output, "Setup cache-memory git repository",
411 "Should include git setup step")
412 assert.Contains(t, output, "setup_cache_memory_git.sh",
413 "Should reference the git setup script")
414 assert.Contains(t, output, "GH_AW_MIN_INTEGRITY: unapproved",
415 "Should set the integrity level env var")
416 assert.Contains(t, output, "GH_AW_CACHE_DIR: /tmp/gh-aw/cache-memory",
417 "Should set the cache dir env var")
418}
419
420// TestCacheMemoryStepsIntegrityAwareKey verifies that the generated cache key
421// includes the integrity level and policy hash.

Callers

nothing calls this directly

Calls 6

ParseToolsConfigFunction · 0.85
NewCompilerFunction · 0.85
NewToolsFunction · 0.85
generateCacheMemoryStepsFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected