-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial CLI command tests #305
Conversation
ab969d7
to
5ff644f
Compare
@JosephGJ I rebased for you and force pushed. To update your branch:
|
@JosephGJ I updated the test command for you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests pass. Nice work @JosephGJ. I've got trivial comments for you to address, but overall, great job.
"testing" | ||
"time" | ||
|
||
// Amplifier |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment not necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments removed.
"google.golang.org/grpc" | ||
) | ||
|
||
type TestSpec struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't export test types in the cli package. Better yet, rename this package to cli_test
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test types removed.
dockerDefaultVersion = "1.24" | ||
) | ||
|
||
// Amplifier |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed unnecessary amplifier setup code. Used the StartTestServer function suggested.
} | ||
|
||
func TestCmds(t *testing.T) { | ||
parseEnv() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need this (you needed it for TestMain
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed from TestCmds
} | ||
commandFinal := append(cmdSplit, spec.Args...) | ||
commandFinal = append(commandFinal, optionsSplit...) | ||
fmt.Println(commandFinal, "Command passed") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use fmt
for tests; instead, use t.Log
, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
t.Log used in every instance of a fmt.Print statement.
} | ||
|
||
func RunCmd(t *testing.T, cmdString []string) { | ||
fmt.Println(cmdString, "Running...") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same: don't use fmt
} else { | ||
fmt.Print(cmdString, " Command result:\n", string(result)) | ||
} | ||
time.Sleep(2 * time.Second) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the Sleep call? cmd.CombinedOutput()
blocks until finished, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sleep call removed. Replaced with a for loop for recursing a command that fails. Primarly for the purpose of ensure that the pinger isn't curled before pinger has appeared in the swarm.
Modified to take into account tony's comments:
Same test as before: Will continue to working on Cli command tests. |
testSpec := &TestSpec{ | ||
fileName: name, | ||
contents: contents, | ||
valid: valid, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$ go test github.com/appcelerator/amp/cmd/amp/cli
# github.com/appcelerator/amp/cmd/amp/cli_test
cmd/amp/cli/cli_test.go:59: undefined: valid
FAIL github.com/appcelerator/amp/cmd/amp/cli [build failed]
Don't merge |
6c86c34
to
d3361f6
Compare
d3361f6
to
defdec3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, @JosephGJ 👍
* Initial Cli command Tests (#305) * Added -l -n and -a to amp stack ls
Closes #284
To test: