From 23efd79a6c6c574ce784161ee32a996bd977773c Mon Sep 17 00:00:00 2001 From: Soulou Date: Fri, 1 Apr 2016 20:34:15 +0200 Subject: [PATCH] golint govet gotest --- config/auth_test.go | 33 ++++++++++++++++++++------------- env/edit_test.go | 13 ------------- net/ssh/client.go | 2 +- 3 files changed, 21 insertions(+), 27 deletions(-) diff --git a/config/auth_test.go b/config/auth_test.go index c83bd7f90..49a057047 100644 --- a/config/auth_test.go +++ b/config/auth_test.go @@ -1,16 +1,18 @@ package config import ( + "encoding/json" "testing" "github.com/Scalingo/cli/Godeps/_workspace/src/github.com/Scalingo/go-scalingo" + "github.com/Scalingo/cli/config/auth" ) var ( u = &scalingo.User{ - Email: "test@example.com", - Username: "test", - AuthToken: "0123456789", + Email: "test@example.com", + Username: "test", + AuthenticationToken: "0123456789", } ) @@ -48,15 +50,18 @@ func TestStoreAuth(t *testing.T) { func TestExistingAuth(t *testing.T) { // Before any auth - auth, err := existingAuth() + currentAuth, err := existingAuth() if err != nil { t.Errorf("%v should be nil", err) } - if len(auth.AuthConfigPerHost) > 0 { - t.Errorf("want auth.AuthConfigPerHost = [], got %v", auth.AuthConfigPerHost) + var configPerHost auth.ConfigPerHostV1 + json.Unmarshal(currentAuth.AuthConfigPerHost, &configPerHost) + + if len(configPerHost) > 0 { + t.Errorf("want auth.AuthConfigPerHost = [], got %v", configPerHost) } - if !auth.LastUpdate.IsZero() { - t.Errorf("auth should never have been updated: %v", auth.LastUpdate) + if !currentAuth.LastUpdate.IsZero() { + t.Errorf("auth should never have been updated: %v", currentAuth.LastUpdate) } // After one auth @@ -64,15 +69,17 @@ func TestExistingAuth(t *testing.T) { if err != nil { t.Errorf("%v should be nil", err) } - auth, err = existingAuth() + + currentAuth, err = existingAuth() + json.Unmarshal(currentAuth.AuthConfigPerHost, &configPerHost) if err != nil { t.Errorf("%v should be nil", err) } - if len(auth.AuthConfigPerHost) != 1 { - t.Errorf("want len(auth.AuthConfigPerHost) = 1, got %v", auth.AuthConfigPerHost) + if len(configPerHost) != 1 { + t.Errorf("want len(auth.AuthConfigPerHost) = 1, got %v", configPerHost) } - if auth.LastUpdate.IsZero() { - t.Errorf("auth should have been updated: %v", auth.LastUpdate) + if currentAuth.LastUpdate.IsZero() { + t.Errorf("auth should have been updated: %v", currentAuth.LastUpdate) } clean() diff --git a/env/edit_test.go b/env/edit_test.go index c4926fbe4..fcc25fd32 100644 --- a/env/edit_test.go +++ b/env/edit_test.go @@ -1,7 +1,5 @@ package env -import "bytes" -import "github.com/Scalingo/cli/Godeps/_workspace/src/github.com/Scalingo/go-scalingo" import "testing" func TestAdd(t *testing.T) { @@ -33,17 +31,6 @@ func TestIsEnvEditValid(t *testing.T) { t.Fatal("expected", invalidNameFormatError, "error, got", err) } } - - longName := new(bytes.Buffer) - for i := 0; i < scalingo.EnvNameMaxLength; i++ { - longName.WriteRune('A') - } - longName.WriteString("A=VAL") - if err := isEnvEditValid(longName.String()); err == nil { - t.Fatal(v, "should not be valid") - } else if err != nameTooLongError { - t.Fatal("expected", nameTooLongError, "error, got", err) - } } func TestParseVariable(t *testing.T) { diff --git a/net/ssh/client.go b/net/ssh/client.go index 6477e01e6..8aefa1042 100644 --- a/net/ssh/client.go +++ b/net/ssh/client.go @@ -39,7 +39,7 @@ func Connect(identity string) (*ssh.Client, ssh.Signer, error) { if err != nil { return nil, nil, errgo.Mask(err) } - debug.Println("SSH connection:", client.LocalAddr, "Key:", string(key.PublicKey().Marshal())) + debug.Println("SSH connection:", client.LocalAddr(), "Key:", string(key.PublicKey().Marshal())) return client, key, nil }