Skip to content

Commit c58e237

Browse files
authored
Merge pull request #8 from jaypipes/fix-fail-eval
fix failure evaluation
2 parents f2cbad8 + 4ddf8da commit c58e237

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

.github/workflows/gate-tests.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
test-skip-kind:
1414
strategy:
1515
matrix:
16-
go-version: [1.19.x, 1.20.x]
16+
go: ['1.19', '1.20', '1.21']
1717
os: [macos-latest, windows-latest]
1818
runs-on: ${{ matrix.os }}
1919
steps:
@@ -24,10 +24,15 @@ jobs:
2424
disable-sudo: true
2525
allowed-endpoints: >
2626
github.com:443
27+
api.github.com:443
28+
proxy.github.com:443
29+
raw.githubusercontent.com:443
30+
objects.githubusercontent.com:443
31+
proxy.golang.org:443
2732
- name: checkout code
2833
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
2934
- name: setup go
30-
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
35+
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
3136
with:
3237
go-version: ${{ matrix.go }}
3338
- name: run non-Kind tests
@@ -37,7 +42,7 @@ jobs:
3742
test-all:
3843
strategy:
3944
matrix:
40-
go-version: [1.19.x, 1.20.x]
45+
go: ['1.19', '1.20', '1.21']
4146
os: [ubuntu-latest]
4247
runs-on: ${{ matrix.os }}
4348
steps:
@@ -46,10 +51,17 @@ jobs:
4651
with:
4752
egress-policy: audit
4853
disable-sudo: false
54+
allowed-endpoints: >
55+
github.com:443
56+
api.github.com:443
57+
proxy.github.com:443
58+
raw.githubusercontent.com:443
59+
objects.githubusercontent.com:443
60+
proxy.golang.org:443
4961
- name: checkout code
5062
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
5163
- name: setup go
52-
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
64+
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
5365
with:
5466
go-version: ${{ matrix.go }}
5567
- name: create KinD cluster

assertions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ func (a *assertions) notFoundOK() bool {
340340
// lenOK returns true if the subject matches the Len condition, false otherwise
341341
func (a *assertions) lenOK() bool {
342342
exp := a.exp
343-
if exp.Len != nil {
343+
if exp.Len != nil && a.hasSubject() {
344344
// if the supplied resp is a list of objects returned by the dynamic
345345
// client check its length
346346
list, ok := a.r.(*unstructured.UnstructuredList)

eval.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ func (s *Spec) Eval(ctx context.Context, t *testing.T) *result.Result {
5050
ticker := backoff.NewTicker(bo)
5151
attempts := 0
5252
start := time.Now().UTC()
53+
success := false
5354
for tick := range ticker.C {
5455
attempts++
5556
after := tick.Sub(start)
@@ -64,8 +65,8 @@ func (s *Spec) Eval(ctx context.Context, t *testing.T) *result.Result {
6465
return result.New(result.WithRuntimeError(err))
6566
}
6667
}
67-
a = newAssertions(s.Assert, err, &out)
68-
success := a.OK()
68+
a = newAssertions(s.Assert, err, out)
69+
success = a.OK()
6970
debug.Println(
7071
ctx, t, "%s (try %d after %s) ok: %v",
7172
s.Title(), attempts, after, success,
@@ -81,5 +82,10 @@ func (s *Spec) Eval(ctx context.Context, t *testing.T) *result.Result {
8182
)
8283
}
8384
}
85+
if !success {
86+
for _, fail := range a.Failures() {
87+
t.Error(fail)
88+
}
89+
}
8490
return result.New(result.WithFailures(a.Failures()...))
8591
}

0 commit comments

Comments
 (0)