-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidations_test.go
More file actions
47 lines (41 loc) · 1.07 KB
/
validations_test.go
File metadata and controls
47 lines (41 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package main
import (
"testing"
)
func TestValidateRegistryAgainstSchema(t *testing.T) {
validRegistry := Registry{
Name: "example",
RegistryHost: "https://example.com",
ImageTypes: []string{"snapshots", "releases"},
Default: true,
AuthStrategy: "aws_oidc",
BasePaths: map[string]string{
"services": "/services/path",
"charts": "/charts/path",
},
}
t.Run("Valid registry", func(t *testing.T) {
if err := validateRegistryAgainstSchema(validRegistry); err != nil {
t.Errorf("Expected no error, got %v", err)
}
})
}
func TestValidateRegistryAgainstSchemaInvalid(t *testing.T) {
invalidRegistry := Registry{
Name: "example",
RegistryHost: "https://example.com",
ImageTypes: []string{"NOT_VALID", ""},
Default: true,
AuthStrategy: "NOT_VALID_STRATEGY",
BasePaths: map[string]string{
"services": "/services/path",
},
}
t.Run("Invalid registry", func(t *testing.T) {
if err := validateRegistryAgainstSchema(invalidRegistry); err == nil {
t.Errorf("Expected error, got nil")
} else {
t.Log(err)
}
})
}