chore(go): inject stdin and pass rc force explicitly
This commit is contained in:
@@ -6,9 +6,19 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestNewRejectsNilWriters(t *testing.T) {
|
||||
func TestNewAppRejectsNilReaders(t *testing.T) {
|
||||
t.Run("nil stdin", func(t *testing.T) {
|
||||
app, err := NewApp(nil, &bytes.Buffer{}, &bytes.Buffer{})
|
||||
if err == nil {
|
||||
t.Fatal("expected error for nil stdin")
|
||||
}
|
||||
if app != nil {
|
||||
t.Fatal("expected nil app for nil stdin")
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("nil stdout", func(t *testing.T) {
|
||||
app, err := New(nil, &bytes.Buffer{})
|
||||
app, err := NewApp(new(bytes.Buffer), nil, &bytes.Buffer{})
|
||||
if err == nil {
|
||||
t.Fatal("expected error for nil stdout")
|
||||
}
|
||||
@@ -18,7 +28,7 @@ func TestNewRejectsNilWriters(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("nil stderr", func(t *testing.T) {
|
||||
app, err := New(&bytes.Buffer{}, nil)
|
||||
app, err := NewApp(new(bytes.Buffer), &bytes.Buffer{}, nil)
|
||||
if err == nil {
|
||||
t.Fatal("expected error for nil stderr")
|
||||
}
|
||||
@@ -49,11 +59,12 @@ func TestDeriveDestination(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewInitializesApp(t *testing.T) {
|
||||
func TestNewAppInitializesApp(t *testing.T) {
|
||||
stdin := new(bytes.Buffer)
|
||||
stdout := &bytes.Buffer{}
|
||||
stderr := &bytes.Buffer{}
|
||||
|
||||
app, err := New(stdout, stderr)
|
||||
app, err := NewApp(stdin, stdout, stderr)
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
@@ -61,6 +72,9 @@ func TestNewInitializesApp(t *testing.T) {
|
||||
t.Fatal("expected app instance")
|
||||
}
|
||||
|
||||
if app.Stdin != stdin {
|
||||
t.Fatal("expected stdin reader to be assigned")
|
||||
}
|
||||
if app.Stdout != stdout {
|
||||
t.Fatal("expected stdout writer to be assigned")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user