mirror of
https://github.com/vmware-tanzu/pinniped.git
synced 2026-09-06 16:17:08 +00:00
Drop main module dependency on test module
I suppose we could solve this other ways, but this utility was only used in one place right now, so it is easiest to copy it over. Signed-off-by: Andrew Keesler <akeesler@vmware.com>
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -17,9 +18,17 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/suzerain-io/placeholder-name/pkg/client"
|
||||
"github.com/suzerain-io/placeholder-name/test/library"
|
||||
)
|
||||
|
||||
// errorWriter implements io.Writer by returning a fixed error.
|
||||
type errorWriter struct {
|
||||
returnError error
|
||||
}
|
||||
|
||||
var _ io.Writer = &errorWriter{}
|
||||
|
||||
func (e *errorWriter) Write([]byte) (int, error) { return 0, e.returnError }
|
||||
|
||||
func TestRun(t *testing.T) {
|
||||
spec.Run(t, "main.run", func(t *testing.T, when spec.G, it spec.S) {
|
||||
var r *require.Assertions
|
||||
@@ -86,7 +95,7 @@ func TestRun(t *testing.T) {
|
||||
})
|
||||
|
||||
it("returns an error", func() {
|
||||
err := run(envGetter, tokenExchanger, &library.ErrorWriter{ReturnError: fmt.Errorf("some IO error")}, 30*time.Second)
|
||||
err := run(envGetter, tokenExchanger, &errorWriter{returnError: fmt.Errorf("some IO error")}, 30*time.Second)
|
||||
r.EqualError(err, "failed to marshal response to stdout: some IO error")
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user