diff --git a/cmds/shared_test.go b/cmds/shared_test.go index 290bc2b..de9b629 100644 --- a/cmds/shared_test.go +++ b/cmds/shared_test.go @@ -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" diff --git a/cmds/sqlboiler_test.go b/cmds/sqlboiler_test.go index b7a53bd..86570ef 100644 --- a/cmds/sqlboiler_test.go +++ b/cmds/sqlboiler_test.go @@ -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) - } - } -} - -*/