Skip to content

Commit f53aa81

Browse files
committed
add tests for invalid inputs
1 parent 9d02a5d commit f53aa81

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

pkg/app/test_command_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,16 @@ func Test_TestCommand_Dir(t *testing.T) {
6969
}
7070
}
7171

72+
func Test_TestCommand_Dir_Err(t *testing.T) {
73+
err := TestCommand("http://foo.com/bar", TestCommandContext{Dir: true})
74+
75+
if runtime.GOOS == "windows" {
76+
assert.Contains(t, err.Error(), "Error: Input is not a directory")
77+
} else {
78+
assert.Equal(t, "Error: Input is not a directory", err.Error())
79+
}
80+
}
81+
7282
func Test_TestCommand_Http(t *testing.T) {
7383
defer gock.Off()
7484

@@ -88,6 +98,16 @@ tests:
8898
assert.Contains(t, out, "✓ [local] echo hello")
8999
}
90100

101+
func Test_TestCommand_Http_Err(t *testing.T) {
102+
err := TestCommand("http://error/not/a/url", TestCommandContext{Dir: false})
103+
104+
if runtime.GOOS == "windows" {
105+
assert.NotNil(t, err)
106+
} else {
107+
assert.NotNil(t, err)
108+
}
109+
}
110+
91111
func Test_ConvergeResults(t *testing.T) {
92112
duration, _ := time.ParseDuration("5s")
93113

0 commit comments

Comments
 (0)