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

Function TestRepositoryDiff

environment/integration/repository_test.go:235–262  ·  view source on GitHub ↗

TestRepositoryDiff tests retrieving changes between commits

(t *testing.T)

Source from the content-addressed store, hash-verified

233
234// TestRepositoryDiff tests retrieving changes between commits
235func TestRepositoryDiff(t *testing.T) {
236 t.Parallel()
237 WithRepository(t, "repository-diff", SetupEmptyRepo, func(t *testing.T, repo *repository.Repository, user *UserActions) {
238 ctx := context.Background()
239
240 // Create an environment and make some changes
241 env := user.CreateEnvironment("Test Diff", "Testing repository diff")
242
243 // First commit - add a file
244 user.FileWrite(env.ID, "test.txt", "initial content\n", "Initial commit")
245
246 // Make changes to the file
247 user.FileWrite(env.ID, "test.txt", "initial content\nupdated content\n", "Update file")
248
249 // Get diff output
250 var diffBuf bytes.Buffer
251 err := repo.Diff(ctx, env.ID, &diffBuf)
252 diffOutput := diffBuf.String()
253 require.NoError(t, err, diffOutput)
254
255 // Verify diff contains expected changes
256 assert.Contains(t, diffOutput, "+updated content")
257
258 // Test diff with non-existent environment
259 err = repo.Diff(ctx, "non-existent-env", &diffBuf)
260 assert.Error(t, err)
261 })
262}

Callers

nothing calls this directly

Calls 5

WithRepositoryFunction · 0.85
DiffMethod · 0.80
CreateEnvironmentMethod · 0.45
FileWriteMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected