feat: added test

This commit is contained in:
Itay Kalfon 2024-09-22 18:15:08 +03:00
parent 9717232900
commit 8857602f83
2 changed files with 5 additions and 1 deletions

View File

@ -45,7 +45,7 @@ func parseArgs(argv []string) Op {
if len(argv) > 1 {
return InteractiveSwitchOp{SelfCmd: os.Args[0], Query: argv[1]}
} else {
return UnsupportedOp{Err: fmt.Errorf("'-q' needs arguments")}
return UnsupportedOp{Err: fmt.Errorf("'-q' needs an argument")}
}
} else {
return UnsupportedOp{Err: fmt.Errorf("'-q' only works in interactive mode")}

View File

@ -78,6 +78,10 @@ func Test_parseArgs_new(t *testing.T) {
{name: "too many args",
args: []string{"a", "b", "c"},
want: UnsupportedOp{Err: fmt.Errorf("too many arguments")}},
{name: "missing query",
args: []string{"-q"},
want: UnsupportedOp{Err: fmt.Errorf("'-q' only works in interactive mode")},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {