Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Commit

Permalink
(GH-101) - Add acceptance tests for explain command
Browse files Browse the repository at this point in the history
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
david22swan committed Jan 20, 2022
1 parent ce5c0cf commit 8e64071
Showing 1 changed file with 100 additions and 0 deletions.
100 changes: 100 additions & 0 deletions acceptance/explain/explain_test.go
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)
}

0 comments on commit 8e64071

Please sign in to comment.