From bc27acb22b7c0d715a2093eef8b5bbe69a4ef2f7 Mon Sep 17 00:00:00 2001 From: David Bell Date: Fri, 21 Jul 2017 09:11:18 -0700 Subject: [PATCH] Use url.Parse instead of strings.Replace --- agent/wsclient/client_test.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/agent/wsclient/client_test.go b/agent/wsclient/client_test.go index f7ea2b494c0..10c32706859 100644 --- a/agent/wsclient/client_test.go +++ b/agent/wsclient/client_test.go @@ -15,8 +15,8 @@ package wsclient import ( "io" + "net/url" "os" - "strings" "testing" "github.com/aws/amazon-ecs-agent/agent/acs/model/ecsacs" @@ -171,9 +171,10 @@ func TestHandleIncorrectURLScheme(t *testing.T) { mockServer.StartTLS() defer mockServer.Close() - mockServerURL := strings.Replace(mockServer.URL, "https", "notaparticularlyrealscheme", 1) + mockServerURL, _ := url.Parse(mockServer.URL) + mockServerURL.Scheme = "notaparticularlyrealscheme" - cs := getClientServer(mockServerURL) + cs := getClientServer(mockServerURL.String()) err := cs.Connect() assert.Error(t, err, "Expected error for incorrect URL scheme")