Skip to content

Commit

Permalink
golint govet gotest
Browse files Browse the repository at this point in the history
  • Loading branch information
Soulou committed Apr 1, 2016
1 parent 991f71b commit 23efd79
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 27 deletions.
33 changes: 20 additions & 13 deletions config/auth_test.go
Original file line number Diff line number Diff line change
@@ -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: "[email protected]",
Username: "test",
AuthToken: "0123456789",
Email: "[email protected]",
Username: "test",
AuthenticationToken: "0123456789",
}
)

Expand Down Expand Up @@ -48,31 +50,36 @@ 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
err = Authenticator.StoreAuth(u)
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()
Expand Down
13 changes: 0 additions & 13 deletions env/edit_test.go
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion net/ssh/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 23efd79

Please sign in to comment.