diff --git a/client/client.go b/client/client.go
index 5561f70a77189063aad7c7ada51abb17cd4b72b0..f2c93af0c58e793ae7561c86b640dacf9aafb9cd 100644
--- a/client/client.go
+++ b/client/client.go
@@ -36,6 +36,10 @@ import (
 	"k8s.io/client-go/tools/clientcmd"
 )
 
+const (
+	defaultVersion = "version:v1.7.0"
+)
+
 // Config is a wrapper around client-go's ClientConfig
 type Config struct {
 	Overrides    *clientcmd.ConfigOverrides
@@ -72,10 +76,6 @@ func InitClient(env string) (dynamic.ClientPool, discovery.DiscoveryInterface, s
 // If no swagger is found, or we are unable to authenticate to the server, we
 // will default to version:v1.7.0.
 func (c *Config) GetAPISpec(server string) string {
-	const (
-		defaultVersion = "version:v1.7.0"
-	)
-
 	type Info struct {
 		Version string `json:"version"`
 	}
@@ -111,8 +111,8 @@ func (c *Config) GetAPISpec(server string) string {
 	}
 
 	spec := Spec{}
-	jsonErr := json.Unmarshal(body, &spec)
-	if jsonErr != nil {
+	err = json.Unmarshal(body, &spec)
+	if err != nil {
 		log.Debugf("Failed to parse swagger at %s\n%s", url, err.Error())
 		return defaultVersion
 	}
diff --git a/client/client_test.go b/client/client_test.go
new file mode 100644
index 0000000000000000000000000000000000000000..d474510f6ac4982c6c6932a00c14f9e3aa13721a
--- /dev/null
+++ b/client/client_test.go
@@ -0,0 +1,47 @@
+package client
+
+import (
+	"fmt"
+	"io/ioutil"
+	"net/http"
+	"net/http/httptest"
+	"testing"
+
+	"github.com/stretchr/testify/require"
+)
+
+func TestConfig_GetAPISpec(t *testing.T) {
+	b, err := ioutil.ReadFile("testdata/swagger.json")
+	require.NoError(t, err)
+
+	ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+		fmt.Fprintln(w, string(b))
+	}))
+	defer ts.Close()
+
+	cases := []struct {
+		name      string
+		serverURL string
+		expected  string
+	}{
+		{
+			name:      "invalid server URL",
+			serverURL: "http://+++",
+			expected:  defaultVersion,
+		},
+		{
+			name:      "with a server",
+			serverURL: ts.URL,
+			expected:  "version:v1.9.3",
+		},
+	}
+
+	for _, tc := range cases {
+		t.Run(tc.name, func(t *testing.T) {
+			c := Config{}
+			got := c.GetAPISpec(tc.serverURL)
+			require.Equal(t, tc.expected, got)
+		})
+	}
+
+}
diff --git a/client/testdata/swagger.json b/client/testdata/swagger.json
new file mode 100644
index 0000000000000000000000000000000000000000..342e4dbdd9d608e806ca64cc69bb6466dd1d52ce
--- /dev/null
+++ b/client/testdata/swagger.json
@@ -0,0 +1,5 @@
+{
+    "info": {
+        "version": "v1.9.3"
+    }
+}
\ No newline at end of file