TestRepositoryDiff tests retrieving changes between commits
(t *testing.T)
| 233 | |
| 234 | // TestRepositoryDiff tests retrieving changes between commits |
| 235 | func 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 | } |
nothing calls this directly
no test coverage detected