Example #1
0
func TestGetAllCombinedAppStorageByAccountId(t *testing.T) {
	db := modeltesthelper.NewMongoDB(t)
	defer db.Close()

	acc := createTestAccount(t)

	cs1 := &models.CombinedAppStorage{
		Id:        bson.NewObjectId(),
		AccountId: acc.Id,
	}
	cs2 := &models.CombinedAppStorage{
		Id:        bson.NewObjectId(),
		AccountId: acc.Id,
	}

	if err := modelhelper.CreateCombinedAppStorage(cs1); err != nil {
		t.Fatalf("error should be nil but got:", err)
	}

	if err := modelhelper.CreateCombinedAppStorage(cs2); err != nil {
		t.Fatalf("error should be nil but got:", err)
	}

	if cs1 == nil {
		t.Fatal("CombinedAppStorage should not be nil")
	}

	if cs1.AccountId != acc.Id {
		t.Fatalf("CombinedAppStorage Account id should equal: but got:", acc.Id, cs1.AccountId)
	}

	css, err := modelhelper.GetAllCombinedAppStorageByAccountId(acc.Id)
	if err != nil {
		t.Fatalf("error should be nil but got:", err)
	}

	if len(css) != 2 {
		t.Fatalf("length of CombinedAppStorage should equal to 2, but got:", len(css))
	}

}
Example #2
0
func TestCreateCombinedAppStorage(t *testing.T) {
	db := modeltesthelper.NewMongoDB(t)
	defer db.Close()

	acc := createTestAccount(t)

	cs := &models.CombinedAppStorage{
		Id:        bson.NewObjectId(),
		AccountId: acc.Id,
	}

	if err := modelhelper.CreateCombinedAppStorage(cs); err != nil {
		t.Fatalf("error should be nil but got:", err)
	}

	if cs == nil {
		t.Fatal("CombinedAppStorage should not be nil")
	}

	if cs.AccountId != acc.Id {
		t.Fatalf("CombinedAppStorage Account id should equal: but got:", acc.Id, cs.AccountId)
	}
}