TestUpdateSourceFieldInContent tests the source field update function
(t *testing.T)
| 337 | |
| 338 | // TestUpdateSourceFieldInContent tests the source field update function |
| 339 | func TestUpdateSourceFieldInContent(t *testing.T) { |
| 340 | content := `--- |
| 341 | on: push |
| 342 | source: 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 |
| 367 | func TestMergeWorkflowContent_Integration(t *testing.T) { |
nothing calls this directly
no test coverage detected