From 08895177519224f0d73720cca0e5715db994cb0a Mon Sep 17 00:00:00 2001 From: kylecarbs Date: Wed, 18 May 2022 19:38:40 +0000 Subject: [PATCH] fix: Rename `NewMemoryCoderd` to `NewWithServer` This name felt invalid, because `New` was also in memory. --- coderd/coderd_test.go | 2 +- coderd/coderdtest/coderdtest.go | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/coderd/coderd_test.go b/coderd/coderd_test.go index cc34d89ed6bee..faca9a0ee8a22 100644 --- a/coderd/coderd_test.go +++ b/coderd/coderd_test.go @@ -35,7 +35,7 @@ func TestAuthorizeAllEndpoints(t *testing.T) { t.Parallel() authorizer := &fakeAuthorizer{} - srv, client := coderdtest.NewMemoryCoderd(t, &coderdtest.Options{ + srv, client := coderdtest.NewWithServer(t, &coderdtest.Options{ Authorizer: authorizer, }) admin := coderdtest.CreateFirstUser(t, client) diff --git a/coderd/coderdtest/coderdtest.go b/coderd/coderdtest/coderdtest.go index 117e96e6ac04f..f8e222f73a81d 100644 --- a/coderd/coderdtest/coderdtest.go +++ b/coderd/coderdtest/coderdtest.go @@ -67,7 +67,14 @@ type Options struct { // New constructs an in-memory coderd instance and returns // the connected client. -func NewMemoryCoderd(t *testing.T, options *Options) (*httptest.Server, *codersdk.Client) { +func New(t *testing.T, options *Options) *codersdk.Client { + _, cli := NewWithServer(t, options) + return cli +} + +// NewWithServer returns an in-memory coderd instance and +// the HTTP server it started with. +func NewWithServer(t *testing.T, options *Options) (*httptest.Server, *codersdk.Client) { if options == nil { options = &Options{} } @@ -160,13 +167,6 @@ func NewMemoryCoderd(t *testing.T, options *Options) (*httptest.Server, *codersd return srv, codersdk.New(serverURL) } -// New constructs an in-memory coderd instance and returns -// the connected client. -func New(t *testing.T, options *Options) *codersdk.Client { - _, cli := NewMemoryCoderd(t, options) - return cli -} - // NewProvisionerDaemon launches a provisionerd instance configured to work // well with coderd testing. It registers the "echo" provisioner for // quick testing.