MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / TestCheckRole

Function TestCheckRole

internal/robotaccount/cas/robotaccount_test.go:31–60  ·  view source on GitHub ↗

TestCheckRole tests the CheckRole method

(t *testing.T)

Source from the content-addressed store, hash-verified

29
30// TestCheckRole tests the CheckRole method
31func TestCheckRole(t *testing.T) {
32 tests := []struct {
33 name string
34 gotRole Role
35 wantRole Role
36 wantError bool
37 }{
38 {"downloader", Downloader, Downloader, false},
39 {"uploader", Uploader, Uploader, false},
40 {"invalid", Downloader, "invalid", true},
41 {"does not match", Uploader, Downloader, true},
42 {"does not match", Downloader, Uploader, true},
43 }
44
45 for _, tc := range tests {
46 t.Run(tc.name, func(t *testing.T) {
47 assert := assert.New(t)
48 c := &Claims{
49 Role: tc.gotRole,
50 }
51
52 err := c.CheckRole(tc.wantRole)
53 if tc.wantError {
54 assert.Error(err)
55 } else {
56 assert.NoError(err)
57 }
58 })
59 }
60}
61
62// TestValid tests the Valid method
63func TestValid(t *testing.T) {

Callers

nothing calls this directly

Calls 3

CheckRoleMethod · 0.95
ErrorMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected