Skip to content

Commit

Permalink
first unit test for tournament entity, creating a tournament.
Browse files Browse the repository at this point in the history
involves #308
  • Loading branch information
santiaago committed Mar 2, 2014
1 parent 8257421 commit 55a399c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
2 changes: 1 addition & 1 deletion models/tournament_team.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func TTeamById(c appengine.Context, teamId int64) (*Tteam, error) {

if err := datastore.Get(c, key, &t); err != nil {
log.Errorf(c, "team not found : %v", err)
return &t, err
return nil, err
}
return &t, nil
}
Expand Down
27 changes: 23 additions & 4 deletions models/tournament_team_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,29 @@ func TestTeamById(t *testing.T) {
}
defer c.Close()

// Run code and tests requiring the appengine.Context using c.
log.Infof(c, "Team Test")
log.Infof(c, "Tteam TeamById")

if _, err := TTeamById(c, int64(0)); err != nil {
t.Log(err)
tests := []struct {
name string
id int64
want *Tteam
}{
{
name: "Nil entity",
id: int64(0),
want: nil,
},
}
for _, test := range tests {
got, _ := TTeamById(c, test.id)
if got == nil && test.want != nil {
t.Errorf("TTeamById(%q): got nil wanted %v", test.name, *test.want)
} else if got != nil && test.want == nil {
t.Errorf("TTeamById(%q): got %v wanted nil", test.name, *got)
} else if got == nil && test.want == nil {
// This is OK
} else if *got != *test.want {
t.Errorf("TTeamById(%q): got %v wanted %v", test.name, *got, *test.want)
}
}
}
12 changes: 6 additions & 6 deletions models/user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

package models

import (
"testing"
)
// import (
// "testing"
// )

func TestFetchUserInfo(t *testing.T) {
t.Fatalf("Not implemented")
}
// func TestFetchUserInfo(t *testing.T) {
// t.Fatalf("Not implemented")
// }

0 comments on commit 55a399c

Please sign in to comment.