Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(395)

Side by Side Diff: perf/go/db/db_test.go

Issue 608273002: Add versioning to perf SQL database (Closed) Base URL: https://skia.googlesource.com/buildbot@master
Patch Set: Incorporating feedback 4 Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « perf/go/db/db.go ('k') | perf/go/ingest/main.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 package db
2
3 import (
4 "fmt"
5 "os"
6 "testing"
7 )
8
9 import (
10 // Using 'require' which is like using 'assert' but causes tests to fail .
11 assert "github.com/stretchr/testify/require"
12 )
13
14 // Connection string to the local MySQL database for testing.
15 const MYSQL_DB_OPEN = "root:%s@tcp(localhost:3306)/skia?parseTime=true"
16
17 func TestSQLiteVersioning(t *testing.T) {
18 // Initialize without argument to test against SQLite3
19 Init("")
20 assert.False(t, isMySQL)
21 testDBVersioning(t)
22 }
23
24 func TestMySQLVersioning(t *testing.T) {
25 // Skip this test unless there is an environment variable with the root
26 // password for the local MySQL instance.
27 password := os.Getenv("MYSQL_TESTING_ROOTPW")
28 if password == "" {
29 t.Skip("Skipping versioning tests against MySQL. Set 'MYSQL_TEST ING_ROOTPW' to enable tests.")
30 }
31
32 // Initialize to test against local MySQL db
33 Init(fmt.Sprintf(MYSQL_DB_OPEN, password))
34 assert.True(t, isMySQL)
35 testDBVersioning(t)
36 }
37
38 // Test wether the migration scripts execute.
39 func testDBVersioning(t *testing.T) {
40 // get the DB version
41 dbVersion, err := DBVersion()
42 assert.Nil(t, err)
43 maxVersion := MaxDBVersion()
44
45 // downgrade to 0
46 err = Migrate(0)
47 assert.Nil(t, err)
48 dbVersion, err = DBVersion()
49 assert.Nil(t, err)
50 assert.Equal(t, 0, dbVersion)
51
52 // upgrade the the latest version
53 err = Migrate(maxVersion)
54 assert.Nil(t, err)
55 dbVersion, err = DBVersion()
56 assert.Nil(t, err)
57 assert.Equal(t, maxVersion, dbVersion)
58 }
OLDNEW
« no previous file with comments | « perf/go/db/db.go ('k') | perf/go/ingest/main.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698