Skip to content

Commit

Permalink
add tournament destroy test
Browse files Browse the repository at this point in the history
involves #308
  • Loading branch information
santiaago committed Mar 4, 2014
1 parent e4e9dbf commit 3a2ef2f
Showing 1 changed file with 40 additions and 1 deletion.
41 changes: 40 additions & 1 deletion models/tournament_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestCreateTournament(t *testing.T) {
want *Tournament
}{
{
name: "Nil entity",
name: "Simple create",
tournament: Tournament{
Name: "Foo",
Description: "Foo description",
Expand Down Expand Up @@ -66,3 +66,42 @@ func TestCreateTournament(t *testing.T) {
}
}
}

func TestDestroyTournament(t *testing.T) {
c, err := aetest.NewContext(nil)
if err != nil {
t.Fatal(err)
}
defer c.Close()

log.Infof(c, "Test Destory Tournament")

test := struct {
name string
tournament Tournament
want *Tournament
}{
name: "destroy tournament",
tournament:Tournament{
Name: "Foo",
Description: "Foo description",
Start: time.Now(),
End: time.Now(),
AdminId: int64(0),
},
want:nil,
}

// create tournament
tournament, _ := CreateTournament(c, test.tournament.Name, test.tournament.Description, test.tournament.Start, test.tournament.End, test.tournament.AdminId)

// destory it
if got := tournament.Destroy(c); got != nil{
t.Errorf("TestDestroyTournament(%q): got %v wanted %v", test.name, got, test.want)
}

// make a query on datastore to be sure it is not there.
if got, err1 := TournamentById(c, tournament.Id); err1 == nil{
t.Errorf("TestDestroyTournament(%q): got %v wanted %v", test.name, got, test.want)
}
}

0 comments on commit 3a2ef2f

Please sign in to comment.