-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added unit test for input commands. Now handles wrong sub command pro…
…perly
- Loading branch information
Showing
3 changed files
with
75 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Craig Tomkow | ||
// August 15, 2019 | ||
|
||
package configuration | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
) | ||
|
||
var argTests = []struct { | ||
input string | ||
expected bool | ||
}{ | ||
{"install", true}, | ||
{"remove", true}, | ||
{"start", true}, | ||
{"stop", true}, | ||
{"status", true}, | ||
} | ||
|
||
func TestCommand_MakeCmd(t *testing.T) { | ||
|
||
cmd := new(Command) | ||
|
||
for _, argTest := range argTests { | ||
os.Args = []string{"tto", argTest.input} | ||
err := cmd.MakeCmd() | ||
|
||
switch argTest.input { | ||
case "install": | ||
if argTest.expected != cmd.Install { | ||
t.Errorf("Input arg test failed; found, expected: %t, %t", cmd.Install, argTest.expected) | ||
} | ||
case "remove": | ||
if argTest.expected != cmd.Remove { | ||
t.Errorf("Input arg test failed; found, expected: %t, %t", cmd.Remove, argTest.expected) | ||
} | ||
case "start": | ||
if argTest.expected != cmd.Start { | ||
t.Errorf("Input arg test failed; found, expected: %t, %t", cmd.Start, argTest.expected) | ||
} | ||
case "stop": | ||
if argTest.expected != cmd.Stop { | ||
t.Errorf("Input arg test failed; found, expected: %t, %t", cmd.Stop, argTest.expected) | ||
} | ||
case "status": | ||
if argTest.expected != cmd.Status { | ||
t.Errorf("Input arg test failed; found, expected: %t, %t", cmd.Status, argTest.expected) | ||
} | ||
default: | ||
if err == nil { | ||
t.Errorf("Input arg test failed; found, expected: %t, %t", cmd.Status, argTest.expected) | ||
} | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters