func TestTeamStoreUpdate(t *testing.T) { Setup() o1 := model.Team{} o1.DisplayName = "DisplayName" o1.Name = "a" + model.NewId() + "b" o1.Email = model.NewId() + "@nowhere.com" o1.Type = model.TEAM_OPEN if err := (<-store.Team().Save(&o1)).Err; err != nil { t.Fatal(err) } time.Sleep(100 * time.Millisecond) if err := (<-store.Team().Update(&o1)).Err; err != nil { t.Fatal(err) } o1.Id = "missing" if err := (<-store.Team().Update(&o1)).Err; err == nil { t.Fatal("Update should have failed because of missing key") } o1.Id = model.NewId() if err := (<-store.Team().Update(&o1)).Err; err == nil { t.Fatal("Update should have faile because id change") } }
func TestTeamStoreSave(t *testing.T) { Setup() o1 := model.Team{} o1.DisplayName = "DisplayName" o1.Name = "a" + model.NewId() + "b" o1.Email = model.NewId() + "@nowhere.com" o1.Type = model.TEAM_OPEN if err := (<-store.Team().Save(&o1)).Err; err != nil { t.Fatal("couldn't save item", err) } if err := (<-store.Team().Save(&o1)).Err; err == nil { t.Fatal("shouldn't be able to update from save") } o1.Id = "" if err := (<-store.Team().Save(&o1)).Err; err == nil { t.Fatal("should be unique domain") } }