Skip to content

Commit

Permalink
bumping coverage of stdin/out feature
Browse files Browse the repository at this point in the history
ran prettifier also.
  • Loading branch information
daveshanley committed Dec 30, 2022
1 parent b53a368 commit 9db722d
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 2 deletions.
29 changes: 29 additions & 0 deletions cmd/spectral_report_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/stretchr/testify/assert"
"io"
"os"
"strings"
"testing"
)

Expand Down Expand Up @@ -41,6 +42,34 @@ func TestGetSpectralReportCommand_CustomName(t *testing.T) {
defer os.Remove("blue-shoes.json")
}

func TestGetSpectralReportCommand_StdInOut(t *testing.T) {
cmd := GetSpectralReportCommand()
b := bytes.NewBufferString("")
cmd.SetOut(b)
cmd.SetArgs([]string{"-i", "-o"})
cmd.SetIn(strings.NewReader("openapi: 3.1.0"))
cmdErr := cmd.Execute()
outBytes, err := io.ReadAll(b)

assert.NoError(t, cmdErr)
assert.NoError(t, err)
assert.NotNil(t, outBytes)
}

func TestGetSpectralReportCommand_StdInOutNoPretty(t *testing.T) {
cmd := GetSpectralReportCommand()
b := bytes.NewBufferString("")
cmd.SetOut(b)
cmd.SetArgs([]string{"-i", "-o", "-n"})
cmd.SetIn(strings.NewReader("openapi: 3.1.0"))
cmdErr := cmd.Execute()
outBytes, err := io.ReadAll(b)

assert.NoError(t, cmdErr)
assert.NoError(t, err)
assert.NotNil(t, outBytes)
}

func TestGetSpectralReportCommand_CustomRuleset(t *testing.T) {
cmd := GetSpectralReportCommand()
// global flag exists on root only.
Expand Down
29 changes: 29 additions & 0 deletions cmd/vacuum_report_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/stretchr/testify/assert"
"io"
"os"
"strings"
"testing"
"time"
)
Expand All @@ -29,6 +30,34 @@ func TestGetVacuumReportCommand(t *testing.T) {
defer os.Remove(file)
}

func TestGetVacuumReportCommand_StdInOut(t *testing.T) {
cmd := GetVacuumReportCommand()
b := bytes.NewBufferString("")
cmd.SetOut(b)
cmd.SetArgs([]string{"-i", "-o"})
cmd.SetIn(strings.NewReader("openapi: 3.1.0"))
cmdErr := cmd.Execute()
outBytes, err := io.ReadAll(b)

assert.NoError(t, cmdErr)
assert.NoError(t, err)
assert.NotNil(t, outBytes)
}

func TestGetVacuumReportCommand_NoPretty(t *testing.T) {
cmd := GetVacuumReportCommand()
b := bytes.NewBufferString("")
cmd.SetOut(b)
cmd.SetArgs([]string{"-i", "-o", "-n"})
cmd.SetIn(strings.NewReader("openapi: 3.1.0"))
cmdErr := cmd.Execute()
outBytes, err := io.ReadAll(b)

assert.NoError(t, cmdErr)
assert.NoError(t, err)
assert.NotNil(t, outBytes)
}

func TestGetVacuumReportCommand_Compress(t *testing.T) {
cmd := GetVacuumReportCommand()
b := bytes.NewBufferString("")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ export class ViolationDrawerComponent extends BaseComponent {
<p class="violated">
Learn more about:
<a
href="https://quobix.com/vacuum/rules/${this.category}/${this
.ruleId.replace("$","")}"
href="https://quobix.com/vacuum/rules/${this
.category}/${this.ruleId.replace('$', '')}"
>${this.ruleId}</a
>
</p>
Expand Down

0 comments on commit 9db722d

Please sign in to comment.