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

Function TestUpdateCredSpec

cli/command/service/update_test.go:1270–1370  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1268}
1269
1270func TestUpdateCredSpec(t *testing.T) {
1271 type testCase struct {
1272 // name is the name of the subtest
1273 name string
1274 // flagVal is the value we're setting flagCredentialSpec to
1275 flagVal string
1276 // spec is the existing serviceSpec with its configs
1277 spec *swarm.ContainerSpec
1278 // expected is the expected value of the credential spec after the
1279 // function. it may be nil
1280 expected *swarm.CredentialSpec
1281 }
1282
1283 testCases := []testCase{
1284 {
1285 name: "add file credential spec",
1286 flagVal: "file://somefile",
1287 spec: &swarm.ContainerSpec{},
1288 expected: &swarm.CredentialSpec{File: "somefile"},
1289 }, {
1290 name: "remove a file credential spec",
1291 flagVal: "",
1292 spec: &swarm.ContainerSpec{
1293 Privileges: &swarm.Privileges{
1294 CredentialSpec: &swarm.CredentialSpec{
1295 File: "someFile",
1296 },
1297 },
1298 },
1299 expected: nil,
1300 }, {
1301 name: "remove when no CredentialSpec exists",
1302 flagVal: "",
1303 spec: &swarm.ContainerSpec{},
1304 expected: nil,
1305 }, {
1306 name: "add a config credential spec",
1307 flagVal: "config://someConfigName",
1308 spec: &swarm.ContainerSpec{
1309 Configs: []*swarm.ConfigReference{
1310 {
1311 ConfigName: "someConfigName",
1312 ConfigID: "someConfigID",
1313 Runtime: &swarm.ConfigReferenceRuntimeTarget{},
1314 },
1315 },
1316 },
1317 expected: &swarm.CredentialSpec{
1318 Config: "someConfigID",
1319 },
1320 }, {
1321 name: "remove a config credential spec",
1322 flagVal: "",
1323 spec: &swarm.ContainerSpec{
1324 Privileges: &swarm.Privileges{
1325 CredentialSpec: &swarm.CredentialSpec{
1326 Config: "someConfigID",
1327 },

Callers

nothing calls this directly

Calls 3

updateCredSpecConfigFunction · 0.85
newUpdateCommandFunction · 0.70
SetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…