Skip to content

Commit

Permalink
types
Browse files Browse the repository at this point in the history
  • Loading branch information
myleshorton committed May 20, 2016
1 parent 856d0d9 commit 17346b9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/github.com/getlantern/flashlight/app/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func (s *Settings) checkBool(data map[string]interface{}, name string, f func(bo
}

func (s *Settings) checkInt(data map[string]interface{}, name string, f func(int)) {
if v, ok := data[name].(float64); ok {
if v, ok := data[name].(int); ok {
f(int(v))
} else {
log.Errorf("Could not convert %v in %v", name, data)
Expand Down
14 changes: 7 additions & 7 deletions src/github.com/getlantern/flashlight/app/settings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestRead(t *testing.T) {

s := loadSettingsFrom("1", "1/1/1", "1/1/1", tmpfile.Name())
assert.Equal(t, s.GetProxyAll(), false)
assert.Equal(t, s.GetUserID(), "")
assert.Equal(t, s.GetUserID(), 0)
assert.Equal(t, s.GetSystemProxy(), true)
assert.Equal(t, s.IsAutoReport(), true)

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

// These should be strings, but make sure things don't fail if we send
// These should not be booleans, but make sure things don't fail if we send
// bogus stuff.
m["userID"] = true
m["token"] = true
m["userToken"] = true

in := make(chan interface{}, 100)
in <- m
Expand All @@ -46,7 +46,7 @@ func TestRead(t *testing.T) {
assert.Equal(t, s.GetProxyAll(), true)
assert.Equal(t, s.GetSystemProxy(), false)
assert.Equal(t, s.IsAutoReport(), false)
assert.Equal(t, s.GetUserID(), "")
assert.Equal(t, s.GetUserID(), 0)

// Test that setting something random doesn't break stuff.
m["randomjfdklajfla"] = "fadldjfdla"
Expand All @@ -55,12 +55,12 @@ func TestRead(t *testing.T) {
assert.Equal(t, s.GetProxyAll(), true)

// Test with an actual user ID.
id := "qrueiquriqepuriop"
var id = 483109
m["userID"] = id
in <- m
<-out
assert.Equal(t, s.GetUserID(), id)
assert.Equal(t, s.GetProxyAll(), true)
assert.Equal(t, id, s.GetUserID())
assert.Equal(t, true, s.GetProxyAll())
}

func TestNotPersistVersion(t *testing.T) {
Expand Down

0 comments on commit 17346b9

Please sign in to comment.