This repository has been archived by the owner on Apr 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(GH-101) - Add acceptance tests for explain command
Added test's covering the following use cases: - with no args - output set to json - filter by tag - filter by category - displaying a single topic
- Loading branch information
1 parent
ce5c0cf
commit 8e64071
Showing
1 changed file
with
100 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
package explain_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/puppetlabs/pdkgo/acceptance/testutils" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
const APP = "prm" | ||
|
||
func Test_Explain_With_No_Args(t *testing.T) { | ||
testutils.SkipAcceptanceTest(t) | ||
|
||
// Setup | ||
testutils.SetAppName(APP) | ||
|
||
// Exec | ||
stdout, stderr, exitCode := testutils.RunAppCommand("explain", "") | ||
|
||
// Assert | ||
assert.Contains(t, stdout, "README") | ||
assert.Empty(t, stderr) | ||
assert.Equal(t, 0, exitCode) | ||
} | ||
|
||
func Test_Explain_With_List_Set(t *testing.T) { | ||
testutils.SkipAcceptanceTest(t) | ||
|
||
// Setup | ||
testutils.SetAppName(APP) | ||
|
||
// Exec | ||
stdout, stderr, exitCode := testutils.RunAppCommand("explain --list", "") | ||
|
||
// Assert | ||
assert.Contains(t, stdout, "README") | ||
assert.Empty(t, stderr) | ||
assert.Equal(t, 0, exitCode) | ||
} | ||
|
||
func Test_Explain_With_Format_Json(t *testing.T) { | ||
testutils.SkipAcceptanceTest(t) | ||
|
||
// Setup | ||
testutils.SetAppName(APP) | ||
|
||
// Exec | ||
stdout, stderr, exitCode := testutils.RunAppCommand("explain --format json", "") | ||
|
||
// Assert | ||
assert.Contains(t, stdout, "\"Title\":{\"Short\":\"README\",\"Long\":\"Readme\"") | ||
assert.Empty(t, stderr) | ||
assert.Equal(t, 0, exitCode) | ||
} | ||
|
||
func Test_Explain_With_Tag_Filter(t *testing.T) { | ||
testutils.SkipAcceptanceTest(t) | ||
|
||
// Setup | ||
testutils.SetAppName(APP) | ||
|
||
// Exec | ||
stdout, stderr, exitCode := testutils.RunAppCommand("explain --tag meta", "") | ||
|
||
// Assert | ||
assert.Contains(t, stdout, "README") | ||
assert.Empty(t, stderr) | ||
assert.Equal(t, 0, exitCode) | ||
} | ||
|
||
func Test_Explain_With_Cateogry_Filter(t *testing.T) { | ||
testutils.SkipAcceptanceTest(t) | ||
|
||
// Setup | ||
testutils.SetAppName(APP) | ||
|
||
// Exec | ||
stdout, stderr, exitCode := testutils.RunAppCommand("explain --category concept", "") | ||
|
||
// Assert | ||
assert.Contains(t, stdout, "README") | ||
assert.Empty(t, stderr) | ||
assert.Equal(t, 0, exitCode) | ||
} | ||
|
||
func Test_Explain_With_Single_Target(t *testing.T) { | ||
testutils.SkipAcceptanceTest(t) | ||
|
||
// Setup | ||
testutils.SetAppName(APP) | ||
|
||
// Exec | ||
stdout, stderr, exitCode := testutils.RunAppCommand("explain README", "") | ||
|
||
// Assert | ||
assert.Contains(t, stdout, "Puppet Runtime Manager") | ||
assert.Empty(t, stderr) | ||
assert.Equal(t, 0, exitCode) | ||
} |