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

Function TestExtractMetadataFromLockFile

pkg/workflow/lock_schema_test.go:12–136  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestExtractMetadataFromLockFile(t *testing.T) {
13 tests := []struct {
14 name string
15 content string
16 expectMetadata *LockMetadata
17 expectLegacy bool
18 expectError bool
19 }{
20 {
21 name: "valid v1 metadata",
22 content: `# gh-aw-metadata: {"schema_version":"v1","frontmatter_hash":"abc123"}
23name: test
24`,
25 expectMetadata: &LockMetadata{
26 SchemaVersion: LockSchemaV1,
27 FrontmatterHash: "abc123",
28 },
29 expectLegacy: false,
30 expectError: false,
31 },
32 {
33 name: "valid v1 metadata with spaces",
34 content: `# gh-aw-metadata: {"schema_version":"v1","frontmatter_hash":"def456"}
35name: test
36`,
37 expectMetadata: &LockMetadata{
38 SchemaVersion: LockSchemaV1,
39 FrontmatterHash: "def456",
40 },
41 expectLegacy: false,
42 expectError: false,
43 },
44 {
45 name: "legacy format with frontmatter-hash only",
46 content: `# frontmatter-hash: 1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef
47name: test
48`,
49 expectMetadata: &LockMetadata{
50 FrontmatterHash: "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
51 },
52 expectLegacy: true,
53 expectError: false,
54 },
55 {
56 name: "no metadata",
57 content: `name: test
58on: push
59`,
60 expectMetadata: nil,
61 expectLegacy: false,
62 expectError: false,
63 },
64 {
65 name: "malformed JSON metadata",
66 content: `# gh-aw-metadata: {invalid json}
67name: test
68`,
69 expectMetadata: nil,

Callers

nothing calls this directly

Calls 3

RunMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected