From 9ecf675cc227dc78950955db0626ab8d7c1f1dbe Mon Sep 17 00:00:00 2001 From: Steve Streeting Date: Tue, 6 Dec 2016 10:06:23 +0000 Subject: [PATCH] Keep test config local to tests --- api/http_lifecycle_test.go | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/api/http_lifecycle_test.go b/api/http_lifecycle_test.go index d512f071..72013a99 100644 --- a/api/http_lifecycle_test.go +++ b/api/http_lifecycle_test.go @@ -11,10 +11,6 @@ import ( "github.com/stretchr/testify/assert" ) -var ( - testConfig = NewTestConfig() -) - func NewTestConfig() *config.Configuration { c := config.NewFrom(config.Values{}) c.SetManualEndpoint(config.Endpoint{Url: "https://example.com"}) @@ -24,7 +20,7 @@ func TestHttpLifecycleMakesRequestsAgainstAbsolutePath(t *testing.T) { SetupTestCredentialsFunc() defer RestoreCredentialsFunc() - l := api.NewHttpLifecycle(testConfig) + l := api.NewHttpLifecycle(NewTestConfig()) req, err := l.Build(&api.RequestSchema{ Path: "/foo", Operation: api.DownloadOperation, @@ -38,7 +34,7 @@ func TestHttpLifecycleAttachesQueryParameters(t *testing.T) { SetupTestCredentialsFunc() defer RestoreCredentialsFunc() - l := api.NewHttpLifecycle(testConfig) + l := api.NewHttpLifecycle(NewTestConfig()) req, err := l.Build(&api.RequestSchema{ Path: "/foo", Operation: api.DownloadOperation, @@ -55,7 +51,7 @@ func TestHttpLifecycleAttachesBodyWhenPresent(t *testing.T) { SetupTestCredentialsFunc() defer RestoreCredentialsFunc() - l := api.NewHttpLifecycle(testConfig) + l := api.NewHttpLifecycle(NewTestConfig()) req, err := l.Build(&api.RequestSchema{ Operation: api.DownloadOperation, Body: struct { @@ -74,7 +70,7 @@ func TestHttpLifecycleDoesNotAttachBodyWhenEmpty(t *testing.T) { SetupTestCredentialsFunc() defer RestoreCredentialsFunc() - l := api.NewHttpLifecycle(testConfig) + l := api.NewHttpLifecycle(NewTestConfig()) req, err := l.Build(&api.RequestSchema{ Operation: api.DownloadOperation, }) @@ -87,7 +83,7 @@ func TestHttpLifecycleErrsWithoutOperation(t *testing.T) { SetupTestCredentialsFunc() defer RestoreCredentialsFunc() - l := api.NewHttpLifecycle(testConfig) + l := api.NewHttpLifecycle(NewTestConfig()) req, err := l.Build(&api.RequestSchema{ Path: "/foo", }) @@ -110,7 +106,7 @@ func TestHttpLifecycleExecutesRequestWithoutBody(t *testing.T) { req, _ := http.NewRequest("GET", server.URL+"/path", nil) - l := api.NewHttpLifecycle(testConfig) + l := api.NewHttpLifecycle(NewTestConfig()) _, err := l.Execute(req, nil) assert.True(t, called) @@ -135,7 +131,7 @@ func TestHttpLifecycleExecutesRequestWithBody(t *testing.T) { req, _ := http.NewRequest("GET", server.URL+"/path", nil) - l := api.NewHttpLifecycle(testConfig) + l := api.NewHttpLifecycle(NewTestConfig()) resp := new(Response) _, err := l.Execute(req, resp)