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

Function TestLoadRunSummaryInvalidJSON

pkg/cli/logs_summary_test.go:179–201  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

177}
178
179func TestLoadRunSummaryInvalidJSON(t *testing.T) {
180 // Create a temporary directory for testing
181 tmpDir := testutil.TempDir(t, "test-*")
182 runDir := filepath.Join(tmpDir, "run-12345")
183 if err := os.MkdirAll(runDir, 0755); err != nil {
184 t.Fatalf("Failed to create test directory: %v", err)
185 }
186
187 // Write invalid JSON to the summary file
188 summaryPath := filepath.Join(runDir, runSummaryFileName)
189 if err := os.WriteFile(summaryPath, []byte("invalid json {"), 0644); err != nil {
190 t.Fatalf("Failed to write invalid JSON: %v", err)
191 }
192
193 // Try to load the invalid summary
194 loadedSummary, ok := loadRunSummary(runDir, false)
195 if ok {
196 t.Fatal("Expected loadRunSummary to return false for invalid JSON, but it returned true")
197 }
198 if loadedSummary != nil {
199 t.Errorf("Expected nil summary for invalid JSON, but got: %+v", loadedSummary)
200 }
201}
202
203func TestListArtifacts(t *testing.T) {
204 // Create a temporary directory structure for testing

Callers

nothing calls this directly

Calls 3

TempDirFunction · 0.92
loadRunSummaryFunction · 0.85
ErrorfMethod · 0.45

Tested by

no test coverage detected