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

Function TestIsCompiledUpToDate

pkg/cli/status_compiled_test.go:15–78  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13)
14
15func TestIsCompiledUpToDate(t *testing.T) {
16 tmpDir := t.TempDir()
17
18 // Minimal valid workflow markdown
19 mdContent := `---
20name: test-workflow
21on:
22 workflow_dispatch:
23engine: copilot
24---
25
26# Test Workflow
27
28A simple test workflow.
29`
30
31 mdPath := filepath.Join(tmpDir, "test-workflow.md")
32 require.NoError(t, os.WriteFile(mdPath, []byte(mdContent), 0644), "Should write test workflow")
33
34 // Compute the real frontmatter hash for the test markdown
35 cache := parser.NewImportCache("")
36 realHash, err := parser.ComputeFrontmatterHashFromFile(mdPath, cache)
37 require.NoError(t, err, "Should compute frontmatter hash")
38
39 t.Run("matching hash returns Yes", func(t *testing.T) {
40 lockPath := filepath.Join(tmpDir, "test-workflow.lock.yml")
41 lockContent := `# gh-aw-metadata: {"schema_version":"v1","frontmatter_hash":"` + realHash + `"}
42name: test-workflow
43`
44 require.NoError(t, os.WriteFile(lockPath, []byte(lockContent), 0644), "Should write lock file")
45
46 result := isCompiledUpToDate(mdPath, lockPath)
47 assert.Equal(t, "Yes", result, "Matching hash should return Yes")
48 })
49
50 t.Run("mismatched hash returns No", func(t *testing.T) {
51 lockPath := filepath.Join(tmpDir, "mismatched.lock.yml")
52 lockContent := `# gh-aw-metadata: {"schema_version":"v1","frontmatter_hash":"0000000000000000000000000000000000000000000000000000000000000000"}
53name: test-workflow
54`
55 require.NoError(t, os.WriteFile(lockPath, []byte(lockContent), 0644), "Should write lock file")
56
57 result := isCompiledUpToDate(mdPath, lockPath)
58 assert.Equal(t, "No", result, "Mismatched hash should return No")
59 })
60
61 t.Run("legacy lock file without hash returns Yes", func(t *testing.T) {
62 lockPath := filepath.Join(tmpDir, "legacy.lock.yml")
63 lockContent := `#
64# This file was automatically generated by gh-aw. DO NOT EDIT.
65#
66name: test-workflow
67`
68 require.NoError(t, os.WriteFile(lockPath, []byte(lockContent), 0644), "Should write legacy lock file")
69
70 result := isCompiledUpToDate(mdPath, lockPath)
71 assert.Equal(t, "Yes", result, "Legacy lock file without hash should return Yes")
72 })

Callers

nothing calls this directly

Calls 4

NewImportCacheFunction · 0.92
isCompiledUpToDateFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected