storage: hook up conformance tests for SQL

This commit is contained in:
Eric Chiang
2016-09-17 19:01:15 -06:00
committed by Eric Chiang
parent e2bf8ceb63
commit 63f56b4269
4 changed files with 112 additions and 6 deletions

View File

@@ -13,10 +13,24 @@ import (
var neverExpire = time.Now().Add(time.Hour * 24 * 365 * 100)
// StorageFactory is a method for creating a new storage. The returned storage sould be initialized
// but shouldn't have any existing data in it.
type StorageFactory func() storage.Storage
// RunTestSuite runs a set of conformance tests against a storage.
func RunTestSuite(t *testing.T, s storage.Storage) {
t.Run("UpdateAuthRequest", func(t *testing.T) { testUpdateAuthRequest(t, s) })
t.Run("CreateRefresh", func(t *testing.T) { testCreateRefresh(t, s) })
func RunTestSuite(t *testing.T, sf StorageFactory) {
tests := []struct {
name string
run func(t *testing.T, s storage.Storage)
}{
{"UpdateAuthRequest", testUpdateAuthRequest},
{"CreateRefresh", testCreateRefresh},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
test.run(t, sf())
})
}
}
func testUpdateAuthRequest(t *testing.T, s storage.Storage) {