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

Function TestUpdateSourceFieldInContent

pkg/cli/update_command_test.go:339–364  ·  view source on GitHub ↗

TestUpdateSourceFieldInContent tests the source field update function

(t *testing.T)

Source from the content-addressed store, hash-verified

337
338// TestUpdateSourceFieldInContent tests the source field update function
339func TestUpdateSourceFieldInContent(t *testing.T) {
340 content := `---
341on: push
342source: old/repo/workflow.md@v1.0.0
343---
344
345# Test Workflow`
346
347 updated, err := UpdateFieldInFrontmatter(content, "source", "old/repo/workflow.md@v2.0.0")
348 if err != nil {
349 t.Fatalf("Expected no error, got: %v", err)
350 }
351
352 if !strings.Contains(updated, "source: old/repo/workflow.md@v2.0.0") {
353 t.Errorf("Expected source field to be updated to v2.0.0, got:\n%s", updated)
354 }
355
356 // Ensure other content is preserved (formatting should be preserved)
357 if !strings.Contains(updated, `on: push`) {
358 t.Errorf("Expected other frontmatter fields to be preserved, got:\n%s", updated)
359 }
360
361 if !strings.Contains(updated, "# Test Workflow") {
362 t.Error("Expected markdown content to be preserved")
363 }
364}
365
366// TestMergeWorkflowContent_Integration tests the merge with temporary files
367func TestMergeWorkflowContent_Integration(t *testing.T) {

Callers

nothing calls this directly

Calls 3

UpdateFieldInFrontmatterFunction · 0.85
ErrorfMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected