Refactoring, worked on middleware unit tests, and began thinking about api unit tests, #1921

This commit is contained in:
Torkel Ödegaard
2015-05-01 16:23:36 +02:00
parent d1e9b6d6ae
commit cb8110cd48
7 changed files with 99 additions and 47 deletions
@@ -1,12 +1,9 @@
package migrations
import (
"fmt"
"strings"
"testing"
"github.com/go-xorm/xorm"
"github.com/grafana/grafana/pkg/log"
. "github.com/grafana/grafana/pkg/services/sqlstore/migrator"
"github.com/grafana/grafana/pkg/services/sqlstore/sqlutil"
@@ -16,7 +13,7 @@ import (
var indexTypes = []string{"Unknown", "INDEX", "UNIQUE INDEX"}
func TestMigrations(t *testing.T) {
log.NewLogger(0, "console", `{"level": 0}`)
//log.NewLogger(0, "console", `{"level": 0}`)
testDBs := []sqlutil.TestDB{
sqlutil.TestDB_Sqlite3,
@@ -31,30 +28,30 @@ func TestMigrations(t *testing.T) {
sqlutil.CleanDB(x)
mg := NewMigrator(x)
mg.LogLevel = log.DEBUG
//mg.LogLevel = log.DEBUG
AddMigrations(mg)
err = mg.Start()
So(err, ShouldBeNil)
tables, err := x.DBMetas()
So(err, ShouldBeNil)
fmt.Printf("\nDB Schema after migration: table count: %v\n", len(tables))
for _, table := range tables {
fmt.Printf("\nTable: %v \n", table.Name)
for _, column := range table.Columns() {
fmt.Printf("\t %v \n", column.String(x.Dialect()))
}
if len(table.Indexes) > 0 {
fmt.Printf("\n\tIndexes:\n")
for _, index := range table.Indexes {
fmt.Printf("\t %v (%v) %v \n", index.Name, strings.Join(index.Cols, ","), indexTypes[index.Type])
}
}
}
// tables, err := x.DBMetas()
// So(err, ShouldBeNil)
//
// fmt.Printf("\nDB Schema after migration: table count: %v\n", len(tables))
//
// for _, table := range tables {
// fmt.Printf("\nTable: %v \n", table.Name)
// for _, column := range table.Columns() {
// fmt.Printf("\t %v \n", column.String(x.Dialect()))
// }
//
// if len(table.Indexes) > 0 {
// fmt.Printf("\n\tIndexes:\n")
// for _, index := range table.Indexes {
// fmt.Printf("\t %v (%v) %v \n", index.Name, strings.Join(index.Cols, ","), indexTypes[index.Type])
// }
// }
// }
})
}
}
-1
View File
@@ -10,7 +10,6 @@ import (
)
func TestAccountDataAccess(t *testing.T) {
Convey("Testing Account DB Access", t, func() {
InitTestDB(t)
View File