From 31e6d8fbb1e55ea76c0f1dd3bcd00371211fa785 Mon Sep 17 00:00:00 2001 From: Andrew Keesler Date: Thu, 6 Aug 2020 10:29:04 -0400 Subject: [PATCH] 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 --- cmd/placeholder-name/main_test.go | 13 +++++++++++-- go.mod | 2 -- test/library/ioutil.go | 17 ----------------- 3 files changed, 11 insertions(+), 21 deletions(-) delete mode 100644 test/library/ioutil.go diff --git a/cmd/placeholder-name/main_test.go b/cmd/placeholder-name/main_test.go index d8484951..7ec00b2e 100644 --- a/cmd/placeholder-name/main_test.go +++ b/cmd/placeholder-name/main_test.go @@ -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") }) }) diff --git a/go.mod b/go.mod index 299112eb..b73e5989 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,6 @@ module github.com/suzerain-io/placeholder-name go 1.14 require ( - github.com/davecgh/go-spew v1.1.1 github.com/golang/mock v1.4.3 github.com/golangci/golangci-lint v1.29.0 github.com/google/go-cmp v0.5.0 @@ -21,7 +20,6 @@ require ( k8s.io/component-base v0.19.0-rc.0 k8s.io/klog/v2 v2.2.0 k8s.io/kube-aggregator v0.19.0-rc.0 - k8s.io/utils v0.0.0-20200619165400-6e3d28b6ed19 sigs.k8s.io/yaml v1.2.0 ) diff --git a/test/library/ioutil.go b/test/library/ioutil.go deleted file mode 100644 index 44bf24ca..00000000 --- a/test/library/ioutil.go +++ /dev/null @@ -1,17 +0,0 @@ -/* -Copyright 2020 VMware, Inc. -SPDX-License-Identifier: Apache-2.0 -*/ - -package library - -import "io" - -// 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 }