MCPcopy
hub / github.com/dagger/container-use / TestRepositoryMergeCompleted

Function TestRepositoryMergeCompleted

environment/integration/merge_test.go:217–257  ·  view source on GitHub ↗

TestRepositoryMergeCompleted tests merging the same environment multiple times This should result in fast-forward merges since the main branch doesn't diverge

(t *testing.T)

Source from the content-addressed store, hash-verified

215// TestRepositoryMergeCompleted tests merging the same environment multiple times
216// This should result in fast-forward merges since the main branch doesn't diverge
217func TestRepositoryMergeCompleted(t *testing.T) {
218 t.Parallel()
219 WithRepository(t, "repository-merge-completed", SetupEmptyRepo, func(t *testing.T, repo *repository.Repository, user *UserActions) {
220 ctx := context.Background()
221
222 // Create an environment and add initial content
223 env := user.CreateEnvironment("Test Repeated Merge", "Testing repeated merges")
224 user.FileWrite(env.ID, "repeated-file.txt", "initial content", "Add initial file")
225
226 // First merge
227 var mergeOutput1 bytes.Buffer
228 err := repo.Merge(ctx, env.ID, &mergeOutput1)
229 require.NoError(t, err, "First merge should succeed: %s", mergeOutput1.String())
230
231 // Verify first merge content
232 filePath := filepath.Join(repo.SourcePath(), "repeated-file.txt")
233 content, err := os.ReadFile(filePath)
234 require.NoError(t, err)
235 assert.Equal(t, "initial content", string(content))
236
237 // Update the same file in the environment
238 user.FileWrite(env.ID, "repeated-file.txt", "updated content", "Update file content")
239
240 // Second merge
241 var mergeOutput2 bytes.Buffer
242 err = repo.Merge(ctx, env.ID, &mergeOutput2)
243 require.NoError(t, err, "Second merge should succeed: %s", mergeOutput2.String())
244
245 // Verify second merge content
246 content, err = os.ReadFile(filePath)
247 require.NoError(t, err)
248 assert.Equal(t, "updated content", string(content))
249
250 // Verify commit history includes both merges
251 log, err := repository.RunGitCommand(ctx, repo.SourcePath(), "log", "--oneline", "-10")
252 require.NoError(t, err)
253 // Should have commits for both merges or their individual commits
254 assert.Contains(t, log, "Add initial file", "Log should contain initial commit")
255 assert.Contains(t, log, "Update file content", "Log should contain update commit")
256 })
257}

Callers

nothing calls this directly

Calls 7

RunGitCommandFunction · 0.92
WithRepositoryFunction · 0.85
MergeMethod · 0.80
SourcePathMethod · 0.80
CreateEnvironmentMethod · 0.45
FileWriteMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected