OLD | NEW |
1 package expstorage | 1 package expstorage |
2 | 2 |
3 import ( | 3 import ( |
4 "testing" | 4 "testing" |
5 ) | 5 ) |
6 | 6 |
7 import ( | 7 import ( |
8 // Using 'require' which is like using 'assert' but causes tests to fail
. | 8 // Using 'require' which is like using 'assert' but causes tests to fail
. |
9 assert "github.com/stretchr/testify/require" | 9 assert "github.com/stretchr/testify/require" |
10 | 10 |
11 "skia.googlesource.com/buildbot.git/go/database" | 11 "skia.googlesource.com/buildbot.git/go/database" |
12 "skia.googlesource.com/buildbot.git/go/database/testutil" | 12 "skia.googlesource.com/buildbot.git/go/database/testutil" |
13 "skia.googlesource.com/buildbot.git/golden/go/db" | 13 "skia.googlesource.com/buildbot.git/golden/go/db" |
14 "skia.googlesource.com/buildbot.git/golden/go/types" | 14 "skia.googlesource.com/buildbot.git/golden/go/types" |
15 ) | 15 ) |
16 | 16 |
17 func TestExpectationStores(t *testing.T) { | 17 func TestMySQLExpectationsStore(t *testing.T) { |
18 » // Test the memory store. | |
19 » memStore := NewMemExpectationsStore() | |
20 » testExpectationStore(t, memStore) | |
21 | |
22 » // Initialize the DB to use a local SQLite instances. | |
23 » vdb := database.NewVersionedDB(&database.DatabaseConfig{ | |
24 » » SQLiteFilePath: "correctness.db", | |
25 » » MigrationSteps: db.MigrationSteps(), | |
26 » }) | |
27 » sqlStore := NewSQLExpectationStore(vdb) | |
28 » testExpectationStore(t, sqlStore) | |
29 } | |
30 | |
31 func TestMySQLExpecatationsStore(t *testing.T) { | |
32 // Set up the database and make sure it's at the right version. | 18 // Set up the database and make sure it's at the right version. |
33 conf := &database.DatabaseConfig{ | 19 conf := &database.DatabaseConfig{ |
34 MySQLString: testutil.GetTestMySQLConnStr(t, "root", "correct
ness"), | 20 MySQLString: testutil.GetTestMySQLConnStr(t, "root", "correct
ness"), |
35 MigrationSteps: db.MigrationSteps(), | 21 MigrationSteps: db.MigrationSteps(), |
36 } | 22 } |
37 | 23 |
38 // Lock to serialize DB tests | 24 // Lock to serialize DB tests |
39 lockVdb := testutil.GetMySQlLock(t, conf) | 25 lockVdb := testutil.GetMySQlLock(t, conf) |
40 defer func() { | 26 defer func() { |
41 testutil.ReleaseMySQLLock(t, lockVdb) | 27 testutil.ReleaseMySQLLock(t, lockVdb) |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 assert.Equal(t, types.TestClassification(map[string]types.Label{DIGEST_2
1: types.POSITIVE}), foundExps.Tests[TEST_2]) | 91 assert.Equal(t, types.TestClassification(map[string]types.Label{DIGEST_2
1: types.POSITIVE}), foundExps.Tests[TEST_2]) |
106 | 92 |
107 changeExps.RemoveDigests([]string{DIGEST_12}) | 93 changeExps.RemoveDigests([]string{DIGEST_12}) |
108 err = store.Put(changeExps, "user-3") | 94 err = store.Put(changeExps, "user-3") |
109 assert.Nil(t, err) | 95 assert.Nil(t, err) |
110 | 96 |
111 foundExps, err = store.Get(false) | 97 foundExps, err = store.Get(false) |
112 assert.Nil(t, err) | 98 assert.Nil(t, err) |
113 assert.Equal(t, 1, len(foundExps.Tests)) | 99 assert.Equal(t, 1, len(foundExps.Tests)) |
114 } | 100 } |
OLD | NEW |