summaryrefslogtreecommitdiff
path: root/cmd/rr
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2023-02-16 20:50:52 +0100
committerGitHub <[email protected]>2023-02-16 20:50:52 +0100
commit92fc954a0288e9f1ff3948a169edb270867f5d70 (patch)
tree3a94fc09a549f6a0d85d2ae2bf620d2b5a50e644 /cmd/rr
parent30879ba7eb5d4a89df790a79808ebb49444ca6fd (diff)
parente6440526036f874051dd288b084aef8070385bc0 (diff)
[#1468]: pre-release: `v2023.1.0-alpha.2`v2023.1.0-alpha.2
Diffstat (limited to 'cmd/rr')
-rw-r--r--cmd/rr/command_test.go26
1 files changed, 12 insertions, 14 deletions
diff --git a/cmd/rr/command_test.go b/cmd/rr/command_test.go
index 84eef9d7..9b3e5f6a 100644
--- a/cmd/rr/command_test.go
+++ b/cmd/rr/command_test.go
@@ -5,24 +5,24 @@ import (
"io"
"os"
"testing"
+ "time"
"github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/require"
)
func Test_Main(t *testing.T) {
os.Args = []string{"rr", "--help"}
exitFn = func(code int) { assert.Equal(t, 0, code) }
- r, w, err := os.Pipe()
- require.NoError(t, err)
+ r, w, _ := os.Pipe()
os.Stdout = w
main()
_ = w.Close()
buf := new(bytes.Buffer)
- _, err = io.Copy(buf, r)
- require.NoError(t, err)
+
+ _ = r.SetReadDeadline(time.Now().Add(time.Second))
+ _, _ = io.Copy(buf, r)
assert.Contains(t, buf.String(), "Usage:")
assert.Contains(t, buf.String(), "Available Commands:")
@@ -33,15 +33,13 @@ func Test_MainWithoutCommands(t *testing.T) {
os.Args = []string{"rr"}
exitFn = func(code int) { assert.Equal(t, 0, code) }
- r, w, err := os.Pipe()
- require.NoError(t, err)
+ r, w, _ := os.Pipe()
os.Stdout = w
main()
- _ = w.Close()
buf := new(bytes.Buffer)
- _, err = io.Copy(buf, r)
- require.NoError(t, err)
+ _ = r.SetReadDeadline(time.Now().Add(time.Second))
+ _, _ = io.Copy(buf, r)
assert.Contains(t, buf.String(), "Usage:")
assert.Contains(t, buf.String(), "Available Commands:")
@@ -52,15 +50,15 @@ func Test_MainUnknownSubcommand(t *testing.T) {
os.Args = []string{"", "foobar"}
exitFn = func(code int) { assert.Equal(t, 1, code) }
- r, w, err := os.Pipe()
- require.NoError(t, err)
+ r, w, _ := os.Pipe()
os.Stderr = w
main()
_ = w.Close()
buf := new(bytes.Buffer)
- _, err = io.Copy(buf, r)
- require.NoError(t, err)
+
+ _ = r.SetReadDeadline(time.Now().Add(time.Second))
+ _, _ = io.Copy(buf, r)
assert.Contains(t, buf.String(), "unknown command")
assert.Contains(t, buf.String(), "foobar")