@@ -193,4 +193,58 @@ func TestPrettyPrintWithConfigsAndSecrets(t *testing.T) {
193193 assert .Check (t , is .Contains (s , "Configs:" ), "Pretty print missing configs" )
194194 assert .Check (t , is .Contains (s , "Secrets:" ), "Pretty print missing secrets" )
195195 assert .Check (t , is .Contains (s , "Healthcheck:" ), "Pretty print missing healthcheck" )
196+ assert .Check (t , is .Contains (s , "configtest.conf" ), "Pretty print missing config name" )
197+ assert .Check (t , is .Contains (s , "mtc3i44r1awdoziy2iceg73z8" ), "Pretty print missing config ID" )
198+ assert .Check (t , is .Contains (s , "secrettest.conf" ), "Pretty print missing secret name" )
199+ assert .Check (t , is .Contains (s , "3hv39ehbbb4hdozo7spod9ftn" ), "Pretty print missing secret ID" )
200+ }
201+
202+ func TestPrettyPrintWithRuntimeConfig (t * testing.T ) {
203+ b := new (bytes.Buffer )
204+ endpointSpec := & swarm.EndpointSpec {Mode : "vip" }
205+ two := uint64 (2 )
206+
207+ s := swarm.Service {
208+ ID : "runtimeconfigservice" ,
209+ Spec : swarm.ServiceSpec {
210+ Annotations : swarm.Annotations {Name : "runtime_svc" },
211+ TaskTemplate : swarm.TaskSpec {
212+ ContainerSpec : & swarm.ContainerSpec {
213+ Image : "foo/bar:latest" ,
214+ Configs : []* swarm.ConfigReference {
215+ {
216+ ConfigID : "abc123" ,
217+ ConfigName : "my-runtime-config" ,
218+ Runtime : & swarm.ConfigReferenceRuntimeTarget {},
219+ },
220+ },
221+ },
222+ },
223+ Mode : swarm.ServiceMode {
224+ Replicated : & swarm.ReplicatedService {Replicas : & two },
225+ },
226+ EndpointSpec : endpointSpec ,
227+ },
228+ Endpoint : swarm.Endpoint {Spec : * endpointSpec },
229+ }
230+
231+ ctx := formatter.Context {
232+ Output : b ,
233+ Format : newFormat ("pretty" ),
234+ }
235+
236+ err := inspectFormatWrite (ctx , []string {"runtimeconfigservice" },
237+ func (ref string ) (any , []byte , error ) {
238+ return s , nil , nil
239+ },
240+ func (ref string ) (any , []byte , error ) {
241+ return network.Summary {}, nil , nil
242+ },
243+ )
244+ assert .NilError (t , err )
245+ output := b .String ()
246+ assert .Check (t , is .Contains (output , "Configs:" ), "Pretty print missing configs" )
247+ assert .Check (t , is .Contains (output , "[runtime]" ), "Pretty print should show [runtime] for configs without File target" )
248+ assert .Check (t , is .Contains (output , "my-runtime-config" ), "Pretty print missing runtime config name" )
249+ assert .Check (t , is .Contains (output , "abc123" ), "Pretty print missing runtime config ID" )
196250}
0 commit comments