MCPcopy Index your code
hub / github.com/docker/cli / TestConvertCredentialSpec

Function TestConvertCredentialSpec

cli/compose/convert/service_test.go:350–442  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

348}
349
350func TestConvertCredentialSpec(t *testing.T) {
351 tests := []struct {
352 name string
353 in composetypes.CredentialSpecConfig
354 out *swarm.CredentialSpec
355 configs []*swarm.ConfigReference
356 expectedErr string
357 }{
358 {
359 name: "empty",
360 },
361 {
362 name: "config-and-file",
363 in: composetypes.CredentialSpecConfig{Config: "0bt9dmxjvjiqermk6xrop3ekq", File: "somefile.json"},
364 expectedErr: `invalid credential spec: cannot specify both "Config" and "File"`,
365 },
366 {
367 name: "config-and-registry",
368 in: composetypes.CredentialSpecConfig{Config: "0bt9dmxjvjiqermk6xrop3ekq", Registry: "testing"},
369 expectedErr: `invalid credential spec: cannot specify both "Config" and "Registry"`,
370 },
371 {
372 name: "file-and-registry",
373 in: composetypes.CredentialSpecConfig{File: "somefile.json", Registry: "testing"},
374 expectedErr: `invalid credential spec: cannot specify both "File" and "Registry"`,
375 },
376 {
377 name: "config-and-file-and-registry",
378 in: composetypes.CredentialSpecConfig{Config: "0bt9dmxjvjiqermk6xrop3ekq", File: "somefile.json", Registry: "testing"},
379 expectedErr: `invalid credential spec: cannot specify both "Config", "File", and "Registry"`,
380 },
381 {
382 name: "missing-config-reference",
383 in: composetypes.CredentialSpecConfig{Config: "missing"},
384 expectedErr: "invalid credential spec: spec specifies config missing, but no such config can be found",
385 configs: []*swarm.ConfigReference{
386 {
387 ConfigName: "someName",
388 ConfigID: "missing",
389 },
390 },
391 },
392 {
393 name: "namespaced-config",
394 in: composetypes.CredentialSpecConfig{Config: "name"},
395 configs: []*swarm.ConfigReference{
396 {
397 ConfigName: "namespaced-config_name",
398 ConfigID: "someID",
399 },
400 },
401 out: &swarm.CredentialSpec{Config: "someID"},
402 },
403 {
404 name: "config",
405 in: composetypes.CredentialSpecConfig{Config: "someName"},
406 configs: []*swarm.ConfigReference{
407 {

Callers

nothing calls this directly

Calls 3

NewNamespaceFunction · 0.85
convertCredentialSpecFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…