Skip to content

Commit

Permalink
confirm correct writer is used
Browse files Browse the repository at this point in the history
  • Loading branch information
Brooke Hatton committed Mar 23, 2022
1 parent c50e99c commit 48050e3
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 165 deletions.
165 changes: 0 additions & 165 deletions brooke/thing.go

This file was deleted.

36 changes: 36 additions & 0 deletions print_test.go
Expand Up @@ -161,12 +161,24 @@ func TestFprint(t *testing.T) {
pterm.Output = true
for _, randomString := range internal.RandomStrings {
out := captureStdout(func(w io.Writer) {
// set default to null to confirm that its correctly using the provided writer
pterm.SetDefaultOutput(nil)
pterm.Fprint(w, randomString)
})
testza.AssertEqual(t, randomString, out)
}
})

t.Run("confirm defaults to default output when no writer provided", func(t *testing.T) {
pterm.Output = true
for _, randomString := range internal.RandomStrings {
out := captureStdout(func(w io.Writer) {
pterm.Fprint(nil, randomString)
})
testza.AssertEqual(t, randomString, out)
}
})

t.Run("disabled output", func(t *testing.T) {
pterm.Output = false
for _, randomString := range internal.RandomStrings {
Expand All @@ -184,12 +196,24 @@ func TestFprintln(t *testing.T) {
pterm.Output = true
for _, randomString := range internal.RandomStrings {
out := captureStdout(func(w io.Writer) {
// set default to null to confirm that its correctly using the provided writer
pterm.SetDefaultOutput(nil)
pterm.Fprintln(w, randomString)
})
testza.AssertEqual(t, randomString+"\n", out)
}
})

t.Run("confirm defaults to default output when no writer provided", func(t *testing.T) {
pterm.Output = true
for _, randomString := range internal.RandomStrings {
out := captureStdout(func(w io.Writer) {
pterm.Fprintln(nil, randomString)
})
testza.AssertEqual(t, randomString+"\n", out)
}
})

t.Run("disabled output", func(t *testing.T) {
pterm.Output = false
for _, randomString := range internal.RandomStrings {
Expand Down Expand Up @@ -230,12 +254,24 @@ func TestFprinto(t *testing.T) {
pterm.Output = true
for _, randomString := range internal.RandomStrings {
out := captureStdout(func(w io.Writer) {
// set default to null to confirm that its correctly using the provided writer
pterm.SetDefaultOutput(nil)
pterm.Fprinto(w, randomString)
})
testza.AssertEqual(t, "\r"+randomString, out)
}
})

t.Run("confirm defaults to default output when no writer provided", func(t *testing.T) {
pterm.Output = true
for _, randomString := range internal.RandomStrings {
out := captureStdout(func(w io.Writer) {
pterm.Fprinto(nil, randomString)
})
testza.AssertEqual(t, "\r"+randomString, out)
}
})

t.Run("disabled output", func(t *testing.T) {
pterm.Output = false
for _, randomString := range internal.RandomStrings {
Expand Down

0 comments on commit 48050e3

Please sign in to comment.