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

Function TestValidateOCIKeyPair

pkg/credentials/credentials_test.go:51–76  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

49}
50
51func TestValidateOCIKeyPair(t *testing.T) {
52 assert := assert.New(t)
53
54 testCases := []struct {
55 name string
56 input *credentials.OCIKeypair
57 wantError bool
58 }{
59 {"empty secret", &credentials.OCIKeypair{}, true},
60 {"missing repo", &credentials.OCIKeypair{Username: "un", Password: "p"}, true},
61 {"missing username", &credentials.OCIKeypair{Username: "", Password: "p", Repo: "repo"}, true},
62 {"missing password", &credentials.OCIKeypair{Username: "u", Password: "", Repo: "repo"}, true},
63 {"valid creds", &credentials.OCIKeypair{Username: "u", Password: "p", Repo: "repo"}, false},
64 }
65
66 for _, tc := range testCases {
67 t.Run(tc.name, func(t *testing.T) {
68 err := tc.input.Validate()
69 if tc.wantError {
70 assert.Error(err)
71 } else {
72 assert.NoError(err)
73 }
74 })
75 }
76}

Callers

nothing calls this directly

Calls 3

ErrorMethod · 0.65
RunMethod · 0.45
ValidateMethod · 0.45

Tested by

no test coverage detected