| 121 | } |
| 122 | |
| 123 | func TestSecrets(t *testing.T) { |
| 124 | namespace := Namespace{name: "foo"} |
| 125 | |
| 126 | secretText := "this is the first secret" |
| 127 | secretFile := fs.NewFile(t, "convert-secrets", fs.WithContent(secretText)) |
| 128 | defer secretFile.Remove() |
| 129 | |
| 130 | source := map[string]composetypes.SecretConfig{ |
| 131 | "one": { |
| 132 | File: secretFile.Path(), |
| 133 | Labels: map[string]string{"monster": "mash"}, |
| 134 | }, |
| 135 | "ext": { |
| 136 | External: composetypes.External{ |
| 137 | External: true, |
| 138 | }, |
| 139 | }, |
| 140 | } |
| 141 | |
| 142 | specs, err := Secrets(namespace, source) |
| 143 | assert.NilError(t, err) |
| 144 | assert.Assert(t, is.Len(specs, 1)) |
| 145 | secret := specs[0] |
| 146 | assert.Check(t, is.Equal("foo_one", secret.Name)) |
| 147 | assert.Check(t, is.DeepEqual(map[string]string{ |
| 148 | "monster": "mash", |
| 149 | LabelNamespace: "foo", |
| 150 | }, secret.Labels)) |
| 151 | assert.Check(t, is.DeepEqual([]byte(secretText), secret.Data)) |
| 152 | } |
| 153 | |
| 154 | func TestConfigs(t *testing.T) { |
| 155 | namespace := Namespace{name: "foo"} |