summaryrefslogtreecommitdiffstats
path: root/model/access_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'model/access_test.go')
-rw-r--r--model/access_test.go41
1 files changed, 41 insertions, 0 deletions
diff --git a/model/access_test.go b/model/access_test.go
new file mode 100644
index 000000000..e385c0586
--- /dev/null
+++ b/model/access_test.go
@@ -0,0 +1,41 @@
+// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+package model
+
+import (
+ "strings"
+ "testing"
+)
+
+func TestAccessJson(t *testing.T) {
+ a1 := AccessData{}
+ a1.AuthCode = NewId()
+ a1.Token = NewId()
+ a1.RefreshToken = NewId()
+
+ json := a1.ToJson()
+ ra1 := AccessDataFromJson(strings.NewReader(json))
+
+ if a1.Token != ra1.Token {
+ t.Fatal("tokens didn't match")
+ }
+}
+
+func TestAccessIsValid(t *testing.T) {
+ ad := AccessData{}
+
+ if err := ad.IsValid(); err == nil {
+ t.Fatal("should have failed")
+ }
+
+ ad.AuthCode = NewId()
+ if err := ad.IsValid(); err == nil {
+ t.Fatal("should have failed")
+ }
+
+ ad.Token = NewId()
+ if err := ad.IsValid(); err != nil {
+ t.Fatal(err)
+ }
+}