|
1 | 1 | package schema |
2 | 2 |
|
3 | 3 | import ( |
| 4 | + "fmt" |
4 | 5 | "testing" |
5 | 6 |
|
6 | 7 | "gotest.tools/assert" |
@@ -78,6 +79,46 @@ func TestValidateAllowsXFields(t *testing.T) { |
78 | 79 | assert.NilError(t, err) |
79 | 80 | } |
80 | 81 |
|
| 82 | +func TestValidateCredentialSpecs(t *testing.T) { |
| 83 | + config := dict{ |
| 84 | + "version": "99.99", |
| 85 | + "services": dict{ |
| 86 | + "foo": dict{ |
| 87 | + "image": "busybox", |
| 88 | + "credential_spec": dict{ |
| 89 | + "config": "foobar", |
| 90 | + }, |
| 91 | + }, |
| 92 | + }, |
| 93 | + } |
| 94 | + tests := []struct { |
| 95 | + version string |
| 96 | + expectedErr string |
| 97 | + }{ |
| 98 | + {version: "3.0", expectedErr: "credential_spec"}, |
| 99 | + {version: "3.1", expectedErr: "credential_spec"}, |
| 100 | + {version: "3.2", expectedErr: "credential_spec"}, |
| 101 | + {version: "3.3", expectedErr: "config"}, |
| 102 | + {version: "3.4", expectedErr: "config"}, |
| 103 | + {version: "3.5", expectedErr: "config"}, |
| 104 | + {version: "3.6", expectedErr: "config"}, |
| 105 | + {version: "3.7", expectedErr: "config"}, |
| 106 | + } |
| 107 | + |
| 108 | + for _, tc := range tests { |
| 109 | + tc := tc |
| 110 | + t.Run(tc.version, func(t *testing.T) { |
| 111 | + err := Validate(config, tc.version) |
| 112 | + if tc.expectedErr != "" { |
| 113 | + assert.ErrorContains(t, err, fmt.Sprintf("Additional property %s is not allowed", tc.expectedErr)) |
| 114 | + } else { |
| 115 | + assert.NilError(t, err) |
| 116 | + } |
| 117 | + }) |
| 118 | + } |
| 119 | + |
| 120 | +} |
| 121 | + |
81 | 122 | func TestValidateSecretConfigNames(t *testing.T) { |
82 | 123 | config := dict{ |
83 | 124 | "version": "3.5", |
|
0 commit comments