Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix failure evaluation #8

Merged
merged 1 commit into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions .github/workflows/gate-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
test-skip-kind:
strategy:
matrix:
go-version: [1.19.x, 1.20.x]
go: ['1.19', '1.20', '1.21']
os: [macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -24,10 +24,15 @@ jobs:
disable-sudo: true
allowed-endpoints: >
github.com:443
api.github.com:443
proxy.github.com:443
raw.githubusercontent.com:443
objects.githubusercontent.com:443
proxy.golang.org:443
- name: checkout code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: setup go
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
go-version: ${{ matrix.go }}
- name: run non-Kind tests
Expand All @@ -37,7 +42,7 @@ jobs:
test-all:
strategy:
matrix:
go-version: [1.19.x, 1.20.x]
go: ['1.19', '1.20', '1.21']
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -46,10 +51,17 @@ jobs:
with:
egress-policy: audit
disable-sudo: false
allowed-endpoints: >
github.com:443
api.github.com:443
proxy.github.com:443
raw.githubusercontent.com:443
objects.githubusercontent.com:443
proxy.golang.org:443
- name: checkout code
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: setup go
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
go-version: ${{ matrix.go }}
- name: create KinD cluster
Expand Down
2 changes: 1 addition & 1 deletion assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ func (a *assertions) notFoundOK() bool {
// lenOK returns true if the subject matches the Len condition, false otherwise
func (a *assertions) lenOK() bool {
exp := a.exp
if exp.Len != nil {
if exp.Len != nil && a.hasSubject() {
// if the supplied resp is a list of objects returned by the dynamic
// client check its length
list, ok := a.r.(*unstructured.UnstructuredList)
Expand Down
10 changes: 8 additions & 2 deletions eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func (s *Spec) Eval(ctx context.Context, t *testing.T) *result.Result {
ticker := backoff.NewTicker(bo)
attempts := 0
start := time.Now().UTC()
success := false
for tick := range ticker.C {
attempts++
after := tick.Sub(start)
Expand All @@ -64,8 +65,8 @@ func (s *Spec) Eval(ctx context.Context, t *testing.T) *result.Result {
return result.New(result.WithRuntimeError(err))
}
}
a = newAssertions(s.Assert, err, &out)
success := a.OK()
a = newAssertions(s.Assert, err, out)
success = a.OK()
debug.Println(
ctx, t, "%s (try %d after %s) ok: %v",
s.Title(), attempts, after, success,
Expand All @@ -81,5 +82,10 @@ func (s *Spec) Eval(ctx context.Context, t *testing.T) *result.Result {
)
}
}
if !success {
for _, fail := range a.Failures() {
t.Error(fail)
}
}
return result.New(result.WithFailures(a.Failures()...))
}
Loading