File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -238,6 +238,7 @@ func parseConfig(configVars []string) map[string]interface{} {
238238 configMap [captures [1 ]] = captures [2 ]
239239 } else {
240240 fmt .Printf ("'%s' does not match the pattern 'key=var', ex: MODE=test\n " , config )
241+ os .Exit (1 )
241242 }
242243 }
243244
Original file line number Diff line number Diff line change 1+ package cmd
2+
3+ import (
4+ "os"
5+ "os/exec"
6+ "testing"
7+ )
8+
9+ // Fancy way for testing processes exit unsuccessfully.
10+ // See https://talks.golang.org/2014/testing.slide#23
11+ func TestParseConfig (t * testing.T ) {
12+ if os .Getenv ("TEST_BAD_CONFIG" ) == "1" {
13+ parseConfig ([]string {"FOO=bar" , "CAR star" })
14+ return
15+ }
16+ cmd := exec .Command (os .Args [0 ], "-test.run=TestParseConfig" )
17+ cmd .Env = append (os .Environ (), "TEST_BAD_CONFIG=1" )
18+ err := cmd .Run ()
19+ if e , ok := err .(* exec.ExitError ); ok && ! e .Success () {
20+ return
21+ }
22+ t .Fatalf ("process ran with err %v, want exit status 1" , err )
23+ }
You can’t perform that action at this time.
0 commit comments