diff options
author | Ben Johnson <benbjohnson@yahoo.com> | 2014-07-26 15:11:47 -0600 |
---|---|---|
committer | Ben Johnson <benbjohnson@yahoo.com> | 2014-07-26 15:11:47 -0600 |
commit | ba6badc57f93bdee732fbe177ecbdd84d876ce0f (patch) | |
tree | 942a1ef8f7b30751a7b3bec6db3d5e0bcc7e081b /simulation_test.go | |
parent | Remove wrapping test closures. (diff) | |
download | dedo-ba6badc57f93bdee732fbe177ecbdd84d876ce0f.tar.gz dedo-ba6badc57f93bdee732fbe177ecbdd84d876ce0f.tar.xz |
Move tests to a test package.
Diffstat (limited to 'simulation_test.go')
-rw-r--r-- | simulation_test.go | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/simulation_test.go b/simulation_test.go index 021d6db..1c2aaf8 100644 --- a/simulation_test.go +++ b/simulation_test.go @@ -1,4 +1,4 @@ -package bolt +package bolt_test import ( "bytes" @@ -7,6 +7,7 @@ import ( "sync" "testing" + "github.com/boltdb/bolt" "github.com/stretchr/testify/assert" ) @@ -39,7 +40,7 @@ func testSimulate(t *testing.T, threadCount, parallelism int) { var readerHandlers = []simulateHandler{simulateGetHandler} var writerHandlers = []simulateHandler{simulateGetHandler, simulatePutHandler} - var versions = make(map[txid]*QuickDB) + var versions = make(map[int]*QuickDB) versions[1] = NewQuickDB() db := NewTestDB() @@ -76,9 +77,9 @@ func testSimulate(t *testing.T, threadCount, parallelism int) { // Obtain current state of the dataset. mutex.Lock() - var qdb = versions[tx.id()] + var qdb = versions[tx.ID()] if writable { - qdb = versions[tx.id()-1].Copy() + qdb = versions[tx.ID()-1].Copy() } mutex.Unlock() @@ -86,7 +87,7 @@ func testSimulate(t *testing.T, threadCount, parallelism int) { if writable { defer func() { mutex.Lock() - versions[tx.id()] = qdb + versions[tx.ID()] = qdb mutex.Unlock() assert.NoError(t, tx.Commit()) @@ -117,10 +118,10 @@ func testSimulate(t *testing.T, threadCount, parallelism int) { wg.Wait() } -type simulateHandler func(tx *Tx, qdb *QuickDB) +type simulateHandler func(tx *bolt.Tx, qdb *QuickDB) // Retrieves a key from the database and verifies that it is what is expected. -func simulateGetHandler(tx *Tx, qdb *QuickDB) { +func simulateGetHandler(tx *bolt.Tx, qdb *QuickDB) { // Randomly retrieve an existing exist. keys := qdb.Rand() if len(keys) == 0 { @@ -155,7 +156,7 @@ func simulateGetHandler(tx *Tx, qdb *QuickDB) { } // Inserts a key into the database. -func simulatePutHandler(tx *Tx, qdb *QuickDB) { +func simulatePutHandler(tx *bolt.Tx, qdb *QuickDB) { var err error keys, value := randKeys(), randValue() |