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

Method TestGroupLoader

pkg/policies/policy_groups_test.go:184–228  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

182}
183
184func (s *groupsTestSuite) TestGroupLoader() {
185 cases := []struct {
186 name string
187 ref string
188 expected interface{}
189 wantErr bool
190 }{
191 {
192 name: "file ref",
193 ref: "file://local-policy.yaml",
194 expected: &FileGroupLoader{},
195 },
196 {
197 name: "http ref",
198 ref: "https://myhost/policy.yaml",
199 expected: &HTTPSGroupLoader{},
200 },
201 {
202 name: "invalid ref",
203 ref: "env://environmentvar",
204 wantErr: true,
205 },
206 {
207 name: "empty ref",
208 ref: "",
209 wantErr: true,
210 },
211 }
212
213 for _, tc := range cases {
214 s.Run(tc.name, func() {
215 att := &v1.PolicyGroupAttachment{Ref: tc.ref}
216 loader, err := getGroupLoader(att, &LoadPolicyGroupOptions{
217 Client: nil,
218 Logger: &s.logger,
219 })
220 if tc.wantErr {
221 s.Error(err)
222 return
223 }
224 s.NoError(err)
225 s.IsType(tc.expected, loader)
226 })
227 }
228}
229
230func (s *groupsTestSuite) TestVerifyStatement() {
231 cases := []struct {

Callers

nothing calls this directly

Calls 3

getGroupLoaderFunction · 0.85
ErrorMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected