Skip to content

Commit ceee9cd

Browse files
committed
feat: authztest: categorize test failures by test name
1 parent 19aba30 commit ceee9cd

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

coderd/authz/authz_test.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package authz_test
22

33
import (
4+
"fmt"
45
"math/bits"
56
"strings"
67
"testing"
78

89
"github.com/coder/coder/coderd/authz"
910
"github.com/coder/coder/coderd/authz/authztest"
11+
"github.com/stretchr/testify/require"
1012
)
1113

1214
var nilSet = authztest.Set{nil}
@@ -82,7 +84,7 @@ func Test_ExhaustiveAuthorize(t *testing.T) {
8284
// },
8385
}
8486

85-
var failedTests int
87+
failedTests := make(map[string]int)
8688
//nolint:paralleltest
8789
for _, c := range testCases {
8890
t.Run(c.Name, func(t *testing.T) {
@@ -96,9 +98,9 @@ func Test_ExhaustiveAuthorize(t *testing.T) {
9698
o,
9799
authztest.PermAction)
98100
if c.Result(name) && err != nil {
99-
failedTests++
101+
failedTests[name]++
100102
} else if !c.Result(name) && err == nil {
101-
failedTests++
103+
failedTests[name]++
102104
}
103105
})
104106
v.Reset()
@@ -107,7 +109,9 @@ func Test_ExhaustiveAuthorize(t *testing.T) {
107109
})
108110
}
109111
// TODO: @emyrk when we implement the correct authorize, we can enable this check.
110-
// require.Equal(t, 0, failedTests, fmt.Sprintf("%d tests failed", failedTests))
112+
for testName, numFailed := range failedTests {
113+
require.Zero(t, failedTests[testName], fmt.Sprintf("%s: %d tests failed", testName, numFailed))
114+
}
111115
}
112116

113117
func permissionVariants(all authztest.SetGroup) map[string]*authztest.Role {

0 commit comments

Comments
 (0)