Skip to content

Commit

Permalink
more coverage on settings
Browse files Browse the repository at this point in the history
  • Loading branch information
myleshorton committed May 20, 2016
1 parent 2f525b7 commit a135922
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/github.com/getlantern/flashlight/app/settings_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package app

import (
"encoding/base64"
"io/ioutil"
"os"
"testing"

"code.google.com/p/go-uuid/uuid"

"github.com/stretchr/testify/assert"
)

Expand All @@ -30,6 +33,9 @@ func TestRead(t *testing.T) {
m["autoLaunch"] = false
m["systemProxy"] = false

// This should be a no-op because the device ID is fixed.
m["deviceID"] = "8208fja09493"

// These should not be booleans, but make sure things don't fail if we send
// bogus stuff.
m["userID"] = true
Expand All @@ -40,19 +46,24 @@ func TestRead(t *testing.T) {
out := make(chan interface{})
go s.read(in, out)

//close(in)
<-out

assert.Equal(t, s.GetProxyAll(), true)
assert.Equal(t, s.GetSystemProxy(), false)
assert.Equal(t, s.IsAutoReport(), false)
assert.Equal(t, s.GetUserID(), 0)
assert.Equal(t, s.GetDeviceID(), base64.StdEncoding.EncodeToString(uuid.NodeID()))

// Test that setting something random doesn't break stuff.
m["randomjfdklajfla"] = "fadldjfdla"

// Test tokens while we're at it.
token := "token"
m["userToken"] = token
in <- m
<-out
assert.Equal(t, s.GetProxyAll(), true)
assert.Equal(t, s.GetToken(), token)

// Test with an actual user ID.
var id = 483109
Expand Down

0 comments on commit a135922

Please sign in to comment.