(t *testing.T)
| 144 | } |
| 145 | |
| 146 | func TestRunListWorkflows_CompiledField(t *testing.T) { |
| 147 | tmpDir := t.TempDir() |
| 148 | |
| 149 | // Minimal valid workflow markdown |
| 150 | mdContent := `--- |
| 151 | name: test-workflow |
| 152 | on: |
| 153 | workflow_dispatch: |
| 154 | engine: copilot |
| 155 | --- |
| 156 | |
| 157 | # Test Workflow |
| 158 | |
| 159 | A simple test workflow. |
| 160 | ` |
| 161 | mdPath := filepath.Join(tmpDir, "test-workflow.md") |
| 162 | require.NoError(t, os.WriteFile(mdPath, []byte(mdContent), 0644), "Should write test workflow") |
| 163 | |
| 164 | // Compute the real frontmatter hash |
| 165 | cache := parser.NewImportCache("") |
| 166 | realHash, err := parser.ComputeFrontmatterHashFromFile(mdPath, cache) |
| 167 | require.NoError(t, err, "Should compute frontmatter hash") |
| 168 | |
| 169 | t.Run("compiled Yes when hash matches", func(t *testing.T) { |
| 170 | lockPath := filepath.Join(tmpDir, "test-workflow.lock.yml") |
| 171 | lockContent := `# gh-aw-metadata: {"schema_version":"v1","frontmatter_hash":"` + realHash + `"} |
| 172 | name: test-workflow |
| 173 | ` |
| 174 | require.NoError(t, os.WriteFile(lockPath, []byte(lockContent), 0644), "Should write lock file") |
| 175 | |
| 176 | output := captureListOutput(t, tmpDir, "") |
| 177 | |
| 178 | var items []WorkflowListItem |
| 179 | require.NoError(t, json.Unmarshal([]byte(output), &items), "Should unmarshal JSON output") |
| 180 | require.Len(t, items, 1, "Should have one workflow") |
| 181 | assert.Equal(t, "Yes", items[0].Compiled, "Compiled should be Yes when hash matches") |
| 182 | }) |
| 183 | |
| 184 | t.Run("compiled No when hash mismatches", func(t *testing.T) { |
| 185 | lockPath := filepath.Join(tmpDir, "test-workflow.lock.yml") |
| 186 | lockContent := `# gh-aw-metadata: {"schema_version":"v1","frontmatter_hash":"0000000000000000000000000000000000000000000000000000000000000000"} |
| 187 | name: test-workflow |
| 188 | ` |
| 189 | require.NoError(t, os.WriteFile(lockPath, []byte(lockContent), 0644), "Should write lock file with wrong hash") |
| 190 | |
| 191 | output := captureListOutput(t, tmpDir, "") |
| 192 | |
| 193 | var items []WorkflowListItem |
| 194 | require.NoError(t, json.Unmarshal([]byte(output), &items), "Should unmarshal JSON output") |
| 195 | require.Len(t, items, 1, "Should have one workflow") |
| 196 | assert.Equal(t, "No", items[0].Compiled, "Compiled should be No when hash mismatches") |
| 197 | }) |
| 198 | |
| 199 | t.Run("compiled NA when no lock file", func(t *testing.T) { |
| 200 | // Remove lock file |
| 201 | _ = os.Remove(filepath.Join(tmpDir, "test-workflow.lock.yml")) |
| 202 | |
| 203 | output := captureListOutput(t, tmpDir, "") |
nothing calls this directly
no test coverage detected