Add cleanup between tests for models

pull/324/head
Rob Cutmore 2016-07-15 07:28:11 -04:00
parent e746a86816
commit e028806b5a
1 changed files with 14 additions and 0 deletions

View File

@ -25,6 +25,20 @@ func (s *ModelsSuite) SetUpSuite(c *check.C) {
}
}
func (s *ModelsSuite) TearDownTest(c *check.C) {
// Clear database tables between each test. If new tables are
// used in this test suite they will need to be cleaned up here.
db.Delete(Group{})
db.Delete(Target{})
db.Delete(GroupTarget{})
db.Delete(SMTP{})
db.Delete(Page{})
// Reset users table to default state.
db.Not("id", 1).Delete(User{})
db.Model(User{}).Update("username", "admin")
}
func (s *ModelsSuite) TestGetUser(c *check.C) {
u, err := GetUser(1)
c.Assert(err, check.Equals, nil)