Remove the Gorp dependency
Removed the underlying Gorp package as a dependency & replaced with use of the standard database/sql driver. This removes a dependency and makes this package very lightweight and makes database interactions very transparent. Lastly, from the standpoint of unit testing where you want to mock the database layer instead of requiring a real database, you can now easily use a package like [go-SQLMock](https://github.com/DATA-DOG/go-sqlmock) to do just that. The tests may/not pass for Golang 1.5; it appears that the problem is Travis need to install a linter.
This commit is contained in:
@@ -43,14 +43,14 @@ func TestCleanup(t *testing.T) {
|
||||
// Give the ticker a moment to run.
|
||||
time.Sleep(time.Millisecond * 1500)
|
||||
|
||||
// SELECT expired sessions. We should get a zero-length result slice back.
|
||||
var results []int64
|
||||
_, err = ss.DbMap.Select(&results, "SELECT id FROM http_sessions WHERE expires_on < now()")
|
||||
// SELECT expired sessions. We should get a count of zero back.
|
||||
var count int
|
||||
err = ss.DbPool.QueryRow("SELECT count(*) FROM http_sessions WHERE expires_on < now()").Scan(&count)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to select expired sessions from DB: %v", err)
|
||||
}
|
||||
|
||||
if len(results) > 0 {
|
||||
t.Fatalf("ticker did not delete expired sessions: want 0 got %v", len(results))
|
||||
if count > 0 {
|
||||
t.Fatalf("ticker did not delete expired sessions: want 0 got %v", count)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user