Skip to content

Commit

Permalink
Introduce tests on the config routines
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Mann committed Aug 24, 2017
1 parent 0d4e34c commit 722cad2
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions client_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
)

var client *Client
var clientOpts *ClientOpts
var altClient *Client
var clientSharedWithID string

Expand Down Expand Up @@ -66,7 +67,7 @@ func setup() {
dieErr(err)
}

opts := &ClientOpts{
clientOpts = &ClientOpts{
ClientID: clientDetails.ClientID,
ClientEmail: "",
APIKeyID: clientDetails.ApiKeyID,
Expand All @@ -77,17 +78,17 @@ func setup() {
Logging: false,
}

client, err = GetClient(*opts)
client, err = GetClient(*clientOpts)
if err != nil {
dieErr(err)
}
altClient, err = GetClient(*opts)
altClient, err = GetClient(*clientOpts)
if err != nil {
dieErr(err)
}

// Load another client for later sharing tests
opts = &ClientOpts{
opts := &ClientOpts{
ClientID: shareClientDetails.ClientID,
ClientEmail: "",
APIKeyID: shareClientDetails.ApiKeyID,
Expand Down Expand Up @@ -150,6 +151,28 @@ func TestRegistration(t *testing.T) {
}
}

func TestConfig(t *testing.T) {
profile := "p_" + base64Encode(randomSecretKey()[:8])

if ProfileExists(profile) {
t.Error("Profile already exists")
}

err := SaveConfig(profile, clientOpts)
if err != nil {
t.Error("Unable to save profile")
}

newOpts, err := GetConfig(profile)
if err != nil {
t.Error("Unable to re-read profile")
}

if newOpts.ClientID != clientOpts.ClientID {
t.Error("Invalid profile retrieved")
}
}

func TestGetClientInfo(t *testing.T) {
info, err := client.GetClientInfo(context.Background(), client.Options.ClientID)
if err != nil {
Expand Down

0 comments on commit 722cad2

Please sign in to comment.