storage: Surface "already exists" errors.

This commit is contained in:
rithu john
2017-02-21 15:00:22 -08:00
parent 7e9dc836eb
commit 3df1db1864
7 changed files with 119 additions and 18 deletions

View File

@@ -6,6 +6,7 @@ import (
"testing"
"github.com/Sirupsen/logrus"
sqlite3 "github.com/mattn/go-sqlite3"
)
func TestMigrate(t *testing.T) {
@@ -21,7 +22,15 @@ func TestMigrate(t *testing.T) {
Level: logrus.DebugLevel,
}
c := &conn{db, flavorSQLite3, logger}
errCheck := func(err error) bool {
sqlErr, ok := err.(sqlite3.Error)
if !ok {
return false
}
return sqlErr.ExtendedCode == sqlite3.ErrConstraintUnique
}
c := &conn{db, flavorSQLite3, logger, errCheck}
for _, want := range []int{len(migrations), 0} {
got, err := c.migrate()
if err != nil {