Skip to content

Commit 92676e8

Browse files
committed
test: stabilize CI runs
Disable color in the not-a-git-repo help test so substring assertions match in CI, and seed user.email/user.name in tests that commit so they don't fail on runners without a global git identity.
1 parent a1e6eea commit 92676e8

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

cmd/diffs/main_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ func TestRootCommandRejectsDirectPRTarget(t *testing.T) {
6262
}
6363

6464
func TestLocalCommandRejectsNonGitRepository(t *testing.T) {
65+
t.Setenv("NO_COLOR", "1")
6566
dir := t.TempDir()
6667
var errOut bytes.Buffer
6768
cmd := newRootCommand(time.Time{})

internal/server/server_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,8 @@ func TestOnChangeRunsOnLocalFileChange(t *testing.T) {
242242
func TestOnChangeIgnoresGitCleanBuildOutput(t *testing.T) {
243243
dir := t.TempDir()
244244
git(t, dir, "init")
245+
git(t, dir, "config", "user.email", "test@example.com")
246+
git(t, dir, "config", "user.name", "Test")
245247
writeFile(t, filepath.Join(dir, ".gitignore"), "web/dist/\n")
246248
git(t, dir, "add", ".gitignore")
247249
git(t, dir, "commit", "-m", "init")
@@ -279,6 +281,8 @@ func TestOnChangeIgnoresGitCleanBuildOutput(t *testing.T) {
279281
func TestEventsStreamIgnoresGitCleanBuildOutput(t *testing.T) {
280282
dir := t.TempDir()
281283
git(t, dir, "init")
284+
git(t, dir, "config", "user.email", "test@example.com")
285+
git(t, dir, "config", "user.name", "Test")
282286
writeFile(t, filepath.Join(dir, ".gitignore"), "web/dist/\n")
283287
git(t, dir, "add", ".gitignore")
284288
git(t, dir, "commit", "-m", "init")
@@ -357,6 +361,8 @@ func TestWatcherDisabledDoesNotObserveLocalChanges(t *testing.T) {
357361
func TestGitStatusReturnsChangedPaths(t *testing.T) {
358362
dir := t.TempDir()
359363
git(t, dir, "init")
364+
git(t, dir, "config", "user.email", "test@example.com")
365+
git(t, dir, "config", "user.name", "Test")
360366
writeFile(t, filepath.Join(dir, ".gitignore"), "web/dist/\n")
361367
writeFile(t, filepath.Join(dir, "tracked.txt"), "one\n")
362368
git(t, dir, "add", ".gitignore", "tracked.txt")
@@ -390,6 +396,8 @@ func TestGitStatusReturnsChangedPaths(t *testing.T) {
390396
func TestGitStatusActions(t *testing.T) {
391397
dir := t.TempDir()
392398
git(t, dir, "init")
399+
git(t, dir, "config", "user.email", "test@example.com")
400+
git(t, dir, "config", "user.name", "Test")
393401
writeFile(t, filepath.Join(dir, "tracked.txt"), "one\n")
394402
git(t, dir, "add", "tracked.txt")
395403
git(t, dir, "commit", "-m", "init")

0 commit comments

Comments
 (0)