Closed tonerdo closed 2 years ago
@robmorgan I agree on test cases and I spent some time thinking through them.. Any idea how to mock a cli.Context
? That's my blocker.
@tonerdo you could try to create an integration test in integration_test.go
with something like:
func TestFetchWithStdoutOption(t *testing.T) {
tmpDownloadPath, err := ioutil.TempDir("", "fetch-stdout-test")
require.NoError(t, err)
repoUrl := "https://github.com/gruntwork-io/fetch-test-public"
releaseTag := "v0.0.4"
releaseAsset := "hello+world.txt"
cmd := fmt.Sprintf("fetch --repo %s --tag %s --release-asset %s --stdout false %s", repoUrl, releaseTag, releaseAsset, tmpDownloadPath)
t.Logf("Testing command: %s", cmd)
stdoutput, _, err := runFetchCommandWithOutput(t, cmd)
require.NoError(t, err)
// Ensure the expected file was downloaded
assert.FileExists(t, JoinPath(tmpDownloadPath, releaseAsset))
// When --stdout is specified, ensure the file contents are piped to the standard output stream
assert.Contains(t, stdoutput, "hello world")
}
Maybe if you do a loop with 2 test cases it might cover each code path?
Ah! Didn't realize we had integration tests. Thanks for the pointer
Description
An initial stab at supporting sending the contents of a downloaded asset to standard output
Documentation
TODOs
Please ensure all of these TODOs are completed before asking for a review.
feature/new-vpc-endpoints-955
orbug/missing-count-param-434
.Related Issues
Addresses #101