Add tests to a lot of things.

- Clean up the outputHandler function.
This commit is contained in:
Aaron 2016-03-01 21:37:14 -08:00
commit f179ea54c8
5 changed files with 203 additions and 55 deletions

View file

@ -1,16 +1,58 @@
package cmds
import "testing"
import "github.com/pobri19/sqlboiler/dbdrivers"
func init() {
cmdData = &CmdData{
Tables: []string{"patrick_table"},
Columns: [][]dbdrivers.DBColumn{
[]dbdrivers.DBColumn{
{Name: "patrick_column", IsNullable: false},
},
},
PkgName: "patrick",
OutFolder: "",
DBDriver: nil,
}
}
/*
var testHeader = `package main
import (
)
`
func TestInitTemplates(t *testing.T) {
// TODO(pobr19): Fix this
t.Skip("There's some problem with this test")
templates, err := initTemplates()
templates, err := initTemplates("./templates")
if err != nil {
t.Errorf("Unable to init templates: %s", err)
}
if len(templates) < 2 {
t.Errorf("Expected > 2 templates to be loaded from templates folder, only loaded: %d\n\n%#v", len(templates), templates)
testData := tplData{
Table: "hello_world",
Columns: []dbdrivers.DBColumn{
{Name: "hello_there", Type: "int64", IsNullable: true},
{Name: "enemy_friend_list", Type: "string", IsNullable: false},
},
}
for _, tpl := range templates {
file, err := ioutil.TempFile(os.TempDir(), "boilertemplatetest")
if err != nil {
t.Fatal(err)
}
fmt.Fprintln(testHeader)
if err = tpl.Execute(tpl, testData); err != nil {
t.Error(err)
}
if err = file.Close(); err != nil {
t.Error(err)
}
}
}
*/