commands: Fix TestFixURL
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 11 Apr 2018 06:55:50 +0000 (08:55 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 11 Apr 2018 07:50:19 +0000 (09:50 +0200)
See #4598

commands/server_test.go

index 396b867667d1dedb5e0027f27734baf2fbe8bf2c..8940eb078231d21f64b93e10c428f934328be007 100644 (file)
 
 package commands
 
-//     "testing"
+import (
+       "testing"
 
-//     "github.com/spf13/viper"
+       "github.com/spf13/viper"
+)
 
-// TODO(bep) cli refactor fix me
-/*func TestFixURL(t *testing.T) {
+func TestFixURL(t *testing.T) {
        type data struct {
                TestName   string
                CLIBaseURL string
@@ -41,12 +42,13 @@ package commands
        }
 
        for i, test := range tests {
+               s := newServerCmd()
                v := viper.New()
-               baseURL = test.CLIBaseURL
+               baseURL := test.CLIBaseURL
                v.Set("baseURL", test.CfgBaseURL)
-               serverAppend = test.AppendPort
-               serverPort = test.Port
-               result, err := fixURL(v, baseURL, serverPort)
+               s.serverAppend = test.AppendPort
+               s.serverPort = test.Port
+               result, err := s.fixURL(v, baseURL, s.serverPort)
                if err != nil {
                        t.Errorf("Test #%d %s: unexpected error %s", i, test.TestName, err)
                }
@@ -55,4 +57,3 @@ package commands
                }
        }
 }
-*/