@@ -13,6 +13,7 @@ import (
1313
1414 "github.com/docker/cli/internal/test"
1515 "github.com/moby/moby/api/types/swarm"
16+ "github.com/moby/moby/client"
1617 "gotest.tools/v3/assert"
1718 is "gotest.tools/v3/assert/cmp"
1819 "gotest.tools/v3/golden"
@@ -23,7 +24,7 @@ const configDataFile = "config-create-with-name.golden"
2324func TestConfigCreateErrors (t * testing.T ) {
2425 testCases := []struct {
2526 args []string
26- configCreateFunc func (context.Context , swarm. ConfigSpec ) (swarm. ConfigCreateResponse , error )
27+ configCreateFunc func (context.Context , client. ConfigCreateOptions ) (client. ConfigCreateResult , error )
2728 expectedError string
2829 }{
2930 {
@@ -36,8 +37,8 @@ func TestConfigCreateErrors(t *testing.T) {
3637 },
3738 {
3839 args : []string {"name" , filepath .Join ("testdata" , configDataFile )},
39- configCreateFunc : func (_ context.Context , configSpec swarm. ConfigSpec ) (swarm. ConfigCreateResponse , error ) {
40- return swarm. ConfigCreateResponse {}, errors .New ("error creating config" )
40+ configCreateFunc : func (_ context.Context , options client. ConfigCreateOptions ) (client. ConfigCreateResult , error ) {
41+ return client. ConfigCreateResult {}, errors .New ("error creating config" )
4142 },
4243 expectedError : "error creating config" ,
4344 },
@@ -61,15 +62,15 @@ func TestConfigCreateWithName(t *testing.T) {
6162 const name = "config-with-name"
6263 var actual []byte
6364 cli := test .NewFakeCli (& fakeClient {
64- configCreateFunc : func (_ context.Context , spec swarm. ConfigSpec ) (swarm. ConfigCreateResponse , error ) {
65- if spec .Name != name {
66- return swarm. ConfigCreateResponse {}, fmt .Errorf ("expected name %q, got %q" , name , spec .Name )
65+ configCreateFunc : func (_ context.Context , options client. ConfigCreateOptions ) (client. ConfigCreateResult , error ) {
66+ if options . Spec .Name != name {
67+ return client. ConfigCreateResult {}, fmt .Errorf ("expected name %q, got %q" , name , options . Spec .Name )
6768 }
6869
69- actual = spec .Data
70+ actual = options . Spec .Data
7071
71- return swarm. ConfigCreateResponse {
72- ID : "ID-" + spec .Name ,
72+ return client. ConfigCreateResult {
73+ ID : "ID-" + options . Spec .Name ,
7374 }, nil
7475 },
7576 })
@@ -100,13 +101,13 @@ func TestConfigCreateWithLabels(t *testing.T) {
100101 }
101102
102103 cli := test .NewFakeCli (& fakeClient {
103- configCreateFunc : func (_ context.Context , spec swarm. ConfigSpec ) (swarm. ConfigCreateResponse , error ) {
104- if ! reflect .DeepEqual (spec , expected ) {
105- return swarm. ConfigCreateResponse {}, fmt .Errorf ("expected %+v, got %+v" , expected , spec )
104+ configCreateFunc : func (_ context.Context , options client. ConfigCreateOptions ) (client. ConfigCreateResult , error ) {
105+ if ! reflect .DeepEqual (options . Spec , expected ) {
106+ return client. ConfigCreateResult {}, fmt .Errorf ("expected %+v, got %+v" , expected , options . Spec )
106107 }
107108
108- return swarm. ConfigCreateResponse {
109- ID : "ID-" + spec .Name ,
109+ return client. ConfigCreateResult {
110+ ID : "ID-" + options . Spec .Name ,
110111 }, nil
111112 },
112113 })
@@ -126,17 +127,17 @@ func TestConfigCreateWithTemplatingDriver(t *testing.T) {
126127 const name = "config-with-template-driver"
127128
128129 cli := test .NewFakeCli (& fakeClient {
129- configCreateFunc : func (_ context.Context , spec swarm. ConfigSpec ) (swarm. ConfigCreateResponse , error ) {
130- if spec .Name != name {
131- return swarm. ConfigCreateResponse {}, fmt .Errorf ("expected name %q, got %q" , name , spec .Name )
130+ configCreateFunc : func (_ context.Context , options client. ConfigCreateOptions ) (client. ConfigCreateResult , error ) {
131+ if options . Spec .Name != name {
132+ return client. ConfigCreateResult {}, fmt .Errorf ("expected name %q, got %q" , name , options . Spec .Name )
132133 }
133134
134- if spec .Templating .Name != expectedDriver .Name {
135- return swarm. ConfigCreateResponse {}, fmt .Errorf ("expected driver %v, got %v" , expectedDriver , spec .Labels )
135+ if options . Spec .Templating .Name != expectedDriver .Name {
136+ return client. ConfigCreateResult {}, fmt .Errorf ("expected driver %v, got %v" , expectedDriver , options . Spec .Labels )
136137 }
137138
138- return swarm. ConfigCreateResponse {
139- ID : "ID-" + spec .Name ,
139+ return client. ConfigCreateResult {
140+ ID : "ID-" + options . Spec .Name ,
140141 }, nil
141142 },
142143 })
0 commit comments