Fixed broken tests

This commit is contained in:
Patrick O'brien 2016-03-16 14:03:34 +10:00
parent 7adc73fa59
commit 6228216ff6
2 changed files with 7 additions and 46 deletions

View file

@ -28,7 +28,7 @@ func TestOutHandler(t *testing.T) {
t.Error(err)
}
if out := buf.String(); out != "hello world\npatrick's dreams\n" {
if out := buf.String(); out != "package patrick\n\nhello world\npatrick's dreams\n" {
t.Errorf("Wrong output: %q", out)
}
}
@ -65,7 +65,7 @@ func TestOutHandlerFiles(t *testing.T) {
if err := outHandler("folder", templateOutputs, &data, &imports{}); err != nil {
t.Error(err)
}
if out := file.String(); out != "hello world\npatrick's dreams\n" {
if out := file.String(); out != "package patrick\n\nhello world\npatrick's dreams\n" {
t.Errorf("Wrong output: %q", out)
}
@ -79,7 +79,7 @@ func TestOutHandlerFiles(t *testing.T) {
if err := outHandler("folder", templateOutputs, &data, &a1); err != nil {
t.Error(err)
}
if out := file.String(); out != "import \"fmt\"\nhello world\npatrick's dreams\n" {
if out := file.String(); out != "package patrick\n\nimport \"fmt\"\nhello world\npatrick's dreams\n" {
t.Errorf("Wrong output: %q", out)
}
@ -93,7 +93,7 @@ func TestOutHandlerFiles(t *testing.T) {
if err := outHandler("folder", templateOutputs, &data, &a2); err != nil {
t.Error(err)
}
if out := file.String(); out != "import \"github.com/spf13/cobra\"\nhello world\npatrick's dreams\n" {
if out := file.String(); out != "package patrick\n\nimport \"github.com/spf13/cobra\"\nhello world\npatrick's dreams\n" {
t.Errorf("Wrong output: %q", out)
}
@ -118,7 +118,9 @@ func TestOutHandlerFiles(t *testing.T) {
t.Error(err)
}
expectedOut := `import (
expectedOut := `package patrick
import (
"errors"
"fmt"

View file

@ -72,44 +72,3 @@ func TestTemplates(t *testing.T) {
t.Errorf("go test cmd execution failed: %s\n\n%s", err, buf.String())
}
}
/*
var testHeader = `package main
import (
)
`
func TestInitTemplates(t *testing.T) {
templates, err := initTemplates("./templates")
if err != nil {
t.Errorf("Unable to init templates: %s", err)
}
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)
}
}
}
*/