Skip to content

Commit

Permalink
Fix spurious test output (#2836)
Browse files Browse the repository at this point in the history
Fix spurious test output in CI.

In CI, we see these specific tests reported as FAILED in the log, but not actually failing. The reason is that `gotestsum` is unable to find the actual "PASS" event emitted, but `go test` does succeed correctly. We have trailing output that isn't newline terminated (while waiting for stdin), which results in the behavior.

Example:
```
=== FAIL: cli/azd/internal/repository TestInitializer_infraSpecFromDetect/api_and_web_with_db (unknown)
Input the name of the app database (PostgreSQL) --- PASS: TestInitializer_infraSpecFromDetect (0.00s)
```
  • Loading branch information
weikanglim authored Oct 6, 2023
1 parent 05dae21 commit 188e1a8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cli/azd/internal/repository/detect_confirm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,12 @@ func Test_detectConfirm_confirm(t *testing.T) {
d.Init(tt.detection, dir)

err = d.Confirm(context.Background())
require.NoError(t, err)

// Print extra newline to avoid mangling `go test -v` final test result output while waiting for final stdin,
// which may result in incorrect `gotestsum` reporting
fmt.Println()

require.NoError(t, err)
require.Equal(t, tt.want, d.Services)
})
}
Expand Down
6 changes: 6 additions & 0 deletions cli/azd/internal/repository/infra_confirm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package repository

import (
"context"
"fmt"
"os"
"strings"
"testing"
Expand Down Expand Up @@ -213,6 +214,11 @@ func TestInitializer_infraSpecFromDetect(t *testing.T) {
}

spec, err := i.infraSpecFromDetect(context.Background(), tt.detect)

// Print extra newline to avoid mangling `go test -v` final test result output while waiting for final stdin,
// which may result in incorrect `gotestsum` reporting
fmt.Println()

require.NoError(t, err)
require.Equal(t, tt.want, spec)
})
Expand Down

0 comments on commit 188e1a8

Please sign in to comment.