MCPcopy Create free account
hub / github.com/nhost/nhost / TestLocalUpdateSecrets

Function TestLocalUpdateSecrets

cli/cmd/configserver/local_test.go:227–333  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

225}
226
227func TestLocalUpdateSecrets(t *testing.T) {
228 t.Parallel()
229
230 cases := []struct {
231 name string
232 secretsRaw string
233 newApp *graph.App
234 expected string
235 }{
236 {
237 // Placeholder values mean "unchanged" — UpdateSecrets must
238 // merge with the on-disk value, never overwriting real
239 // secrets with the placeholder sentinel.
240 name: "placeholder preserves on-disk value",
241 secretsRaw: "kept = 'real-on-disk-value'\n",
242 newApp: secretsApp(&model.ConfigEnvironmentVariable{
243 Name: "kept",
244 Value: placeholderSecretValue,
245 }),
246 expected: "kept = 'real-on-disk-value'\n",
247 },
248 {
249 // A real (non-placeholder) value is a genuine update from
250 // the dashboard — write it through.
251 name: "real value writes through",
252 secretsRaw: "edited = 'old-value'\n",
253 newApp: secretsApp(&model.ConfigEnvironmentVariable{
254 Name: "edited",
255 Value: "new-value",
256 }),
257 expected: "edited = 'new-value'\n",
258 },
259 {
260 // A real value for a name that does not yet exist on disk
261 // is a fresh insert.
262 name: "insert of new name writes through",
263 secretsRaw: "",
264 newApp: secretsApp(&model.ConfigEnvironmentVariable{
265 Name: "fresh",
266 Value: "brand-new",
267 }),
268 expected: "fresh = 'brand-new'\n",
269 },
270 {
271 // A name present on disk but absent from newApp.Secrets is
272 // a delete — it must not be carried over.
273 name: "missing name is deleted",
274 secretsRaw: "stays = 'real-stays'\ndropped = 'real-dropped'\n",
275 newApp: secretsApp(&model.ConfigEnvironmentVariable{
276 Name: "stays",
277 Value: placeholderSecretValue,
278 }),
279 expected: "stays = 'real-stays'\n",
280 },
281 }
282
283 for _, tc := range cases {
284 t.Run(tc.name, func(t *testing.T) {

Callers

nothing calls this directly

Calls 8

UpdateSecretsMethod · 0.95
NewLocalFunction · 0.92
secretsAppFunction · 0.85
FatalfMethod · 0.80
ErrorfMethod · 0.80
NameMethod · 0.65
RunMethod · 0.45
WriteStringMethod · 0.45

Tested by

no test coverage detected