Skip to content
This repository has been archived by the owner on Dec 5, 2023. It is now read-only.

Commit

Permalink
Merge branch 'improvedtests' into apitest
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonrichardsmith committed Aug 22, 2016
2 parents b67842d + c5af298 commit 16e9e30
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
14 changes: 14 additions & 0 deletions db/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,20 @@ func TestInit(t *testing.T) {
}
}

func TestSet(t *testing.T) {
database = "nodb"
err := Set()
if err == nil {
t.Error("Expecting error for no databade found")
}
Register("nodb2", TestDB)
database = "nodb2"
err = Set()
if err != nil {
t.Error(err)
}
}

func TestRegister(t *testing.T) {
l := len(DBTypes)
Register("test2", TestDB)
Expand Down
20 changes: 20 additions & 0 deletions db/mongodb/mongodb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,26 @@ func TestAddUserIDs(t *testing.T) {
}
}

func TestAddressAddId(t *testing.T) {
m := MongoAddress{Address: users.Address{}}
id := bson.NewObjectId()
m.ID = id
m.AddID()
if m.Address.ID != id.Hex() {
t.Error("Expected matching Address Hex")
}
}

func TestCardAddId(t *testing.T) {
m := MongoCard{Card: users.Card{}}
id := bson.NewObjectId()
m.ID = id
m.AddID()
if m.Card.ID != id.Hex() {
t.Error("Expected matching Card Hex")
}
}

func TestCreate(t *testing.T) {
TestMongo.Session = TestServer.Session()
defer TestMongo.Session.Close()
Expand Down
32 changes: 32 additions & 0 deletions users/users_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package users

import (
"reflect"
"testing"
)

func TestAddLinksAdd(t *testing.T) {
domain = "mydomain"
a := Address{ID: "test"}
a.AddLinks()
h := Href{"http://mydomain/addresses/test"}
if !reflect.DeepEqual(a.Links["address"], h) {
t.Error("expected equal address links")
}

}

func TestAddLinksCard(t *testing.T) {
domain = "mydomain"
c := Card{ID: "test"}
c.AddLinks()
h := Href{"http://mydomain/cards/test"}
if !reflect.DeepEqual(c.Links["card"], h) {
t.Error("expected equal address links")
}

}

func TestMaskCC(t *testing.T) {

}

0 comments on commit 16e9e30

Please sign in to comment.