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

Function TestUpdateCommand_MergeIsDefault

pkg/cli/update_integration_test.go:301–360  ·  view source on GitHub ↗

--- Merge Behavior Integration Tests --- TestUpdateCommand_MergeIsDefault verifies that merge is the default behavior when a workflow has local modifications.

(t *testing.T)

Source from the content-addressed store, hash-verified

299// TestUpdateCommand_MergeIsDefault verifies that merge is the default behavior
300// when a workflow has local modifications.
301func TestUpdateCommand_MergeIsDefault(t *testing.T) {
302 skipWithoutGitHubAuth(t)
303
304 setup := setupUpdateIntegrationTest(t)
305 defer setup.cleanup()
306
307 // Create a workflow with a source field that can be fetched
308 workflowContent := `---
309source: github/gh-aw/.github/workflows/smoke-test-push.md@main
310on:
311 workflow_dispatch:
312
313permissions:
314 contents: read
315---
316
317# Test Workflow
318
319Local modification that should be preserved during merge.
320`
321 workflowPath := filepath.Join(setup.workflowsDir, "test-update.md")
322 require.NoError(t, os.WriteFile(workflowPath, []byte(workflowContent), 0644))
323
324 // Commit the workflow to git so hasLocalModifications can detect changes
325 gitAdd := exec.Command("git", "add", "-A")
326 gitAdd.Dir = setup.tempDir
327 require.NoError(t, gitAdd.Run(), "Failed to git add")
328
329 gitCommit := exec.Command("git", "commit", "-m", "initial commit")
330 gitCommit.Dir = setup.tempDir
331 require.NoError(t, gitCommit.Run(), "Failed to git commit")
332
333 // Make a local modification
334 modifiedContent := strings.Replace(workflowContent,
335 "Local modification that should be preserved during merge.",
336 "This is my custom local addition.\n\nLocal modification that should be preserved during merge.",
337 1)
338 require.NoError(t, os.WriteFile(workflowPath, []byte(modifiedContent), 0644))
339
340 // Run update with default merge behavior (no --no-merge flag)
341 cmd := exec.Command(setup.binaryPath, "update", "test-update", "--verbose")
342 cmd.Dir = setup.tempDir
343 output, _ := cmd.CombinedOutput()
344 outputStr := string(output)
345
346 // The command should produce output (may succeed or fail depending on
347 // source repo accessibility, but must attempt merge, not override).
348 t.Logf("Update output: %s", outputStr)
349 assert.NotEmpty(t, outputStr, "Update command should produce output")
350
351 // Verify it does NOT report "override mode" — merge is the default
352 assert.NotContains(t, outputStr, "Using override mode",
353 "Default behavior should use merge, not override")
354
355 // Read the resulting workflow file to verify it still exists
356 updatedContent, err := os.ReadFile(filepath.Join(setup.workflowsDir, "test-update.md"))
357 require.NoError(t, err, "Workflow file should still exist after update")
358 assert.Contains(t, string(updatedContent), "Local modification",

Callers

nothing calls this directly

Calls 3

skipWithoutGitHubAuthFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected