@@ -92,21 +92,21 @@ TWO=2
9292 },
9393 {
9494 options : withDefaultOpts (ExecOptions {Detach : true }),
95- configFile : configfile.ConfigFile {DetachKeys : "de " },
95+ configFile : configfile.ConfigFile {DetachKeys : "ctrl-d,e " },
9696 expected : client.ExecCreateOptions {
9797 Cmd : []string {"command" },
98- DetachKeys : "de " ,
98+ DetachKeys : "ctrl-d,e " ,
9999 },
100100 },
101101 {
102102 options : withDefaultOpts (ExecOptions {
103103 Detach : true ,
104- DetachKeys : "ab " ,
104+ DetachKeys : "ctrl-a,b " ,
105105 }),
106- configFile : configfile.ConfigFile {DetachKeys : "de " },
106+ configFile : configfile.ConfigFile {DetachKeys : "ctrl-d,e " },
107107 expected : client.ExecCreateOptions {
108108 Cmd : []string {"command" },
109- DetachKeys : "ab " ,
109+ DetachKeys : "ctrl-a,b " ,
110110 },
111111 },
112112 {
@@ -147,13 +147,23 @@ TWO=2
147147 }
148148}
149149
150- func TestParseExecNoSuchFile (t * testing.T ) {
151- execOpts := withDefaultOpts (ExecOptions {})
152- assert .Check (t , execOpts .EnvFile .Set ("no-such-env-file" ))
153- execConfig , err := parseExec (execOpts , & configfile.ConfigFile {})
154- assert .ErrorContains (t , err , "no-such-env-file" )
155- assert .Check (t , os .IsNotExist (err ))
156- assert .Check (t , execConfig == nil )
150+ func TestParseExecErrors (t * testing.T ) {
151+ t .Run ("missing env-file" , func (t * testing.T ) {
152+ execOpts := withDefaultOpts (ExecOptions {})
153+ assert .Check (t , execOpts .EnvFile .Set ("no-such-env-file" ))
154+ execConfig , err := parseExec (execOpts , & configfile.ConfigFile {})
155+ assert .ErrorContains (t , err , "no-such-env-file" )
156+ assert .Check (t , os .IsNotExist (err ))
157+ assert .Check (t , execConfig == nil )
158+ })
159+ t .Run ("invalid detach keys" , func (t * testing.T ) {
160+ execOpts := withDefaultOpts (ExecOptions {
161+ DetachKeys : "shift-a" ,
162+ })
163+ execConfig , err := parseExec (execOpts , & configfile.ConfigFile {})
164+ assert .Check (t , is .ErrorContains (err , "invalid detach keys (shift-a):" ))
165+ assert .Check (t , is .Nil (execConfig ))
166+ })
157167}
158168
159169func TestRunExec (t * testing.T ) {
0 commit comments