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

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: Incorporated feedback 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
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.
jcgregorio 2014/09/30 14:54:08 So I need a local MySQL instance to run this test?
stephana 2014/09/30 18:11:50 Yes. I have changed it so that it checks whether t
15 const MYSQL_DB_OPEN = "root:%s@tcp(localhost:3306)/skia?parseTime=true"
16
17 func TestDBVersioning(t *testing.T) {
18 // Initialize without argument to test against SQLite3
19 Init("")
20 assert.False(t, isMySQL)
21 testDBVersioning(t)
22
23 // Initialize to test against local MySQL db
24 Init(fmt.Sprintf(MYSQL_DB_OPEN, os.Getenv("MYSQL_TESTING_ROOTPW")))
25 assert.True(t, isMySQL)
26 testDBVersioning(t)
27 }
28
29 // Test wether the migration scripts execute.
30 func testDBVersioning(t *testing.T) {
31 // get the DB version
32 dbVersion, err := DBVersion()
33 assert.Nil(t, err)
34 maxVersion := MaxDBVersion()
35
36 // downgrade to 0
37 err = Migrate(0)
38 assert.Nil(t, err)
39 dbVersion, err = DBVersion()
40 assert.Nil(t, err)
41 assert.Equal(t, 0, dbVersion)
42
43 // upgrade the the latest version
44 err = Migrate(maxVersion)
45 assert.Nil(t, err)
46 dbVersion, err = DBVersion()
47 assert.Nil(t, err)
48 assert.Equal(t, maxVersion, dbVersion)
49 }
OLDNEW
« perf/go/db/db.go ('K') | « perf/go/db/db.go ('k') | perf/go/migratedb/main.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698