Added parellelism to tests
This commit is contained in:
parent
4cc62fdf5a
commit
896f10199e
3 changed files with 51 additions and 4 deletions
|
@ -138,6 +138,8 @@ patrick's dreams
|
|||
}
|
||||
|
||||
func TestSortImports(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
a1 := []string{
|
||||
`"fmt"`,
|
||||
`"errors"`,
|
||||
|
@ -180,10 +182,9 @@ func TestSortImports(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestBuildImportString(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCombineImports(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
a := imports{
|
||||
standard: []string{"fmt"},
|
||||
thirdparty: []string{"github.com/pobri19/sqlboiler", "gopkg.in/guregu/null.v3"},
|
||||
|
@ -204,6 +205,8 @@ func TestCombineImports(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestRemoveDuplicates(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
hasDups := func(possible []string) error {
|
||||
for i := 0; i < len(possible)-1; i++ {
|
||||
for j := i + 1; j < len(possible); j++ {
|
||||
|
@ -246,6 +249,8 @@ func TestRemoveDuplicates(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCombineStringSlices(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
var a, b []string
|
||||
slice := combineStringSlices(a, b)
|
||||
if ln := len(slice); ln != 0 {
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
package cmds
|
||||
|
||||
import "github.com/pobri19/sqlboiler/dbdrivers"
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/pobri19/sqlboiler/dbdrivers"
|
||||
)
|
||||
|
||||
func init() {
|
||||
cmdData = &CmdData{
|
||||
|
@ -16,6 +20,30 @@ func init() {
|
|||
}
|
||||
}
|
||||
|
||||
// ioutil.TempDir
|
||||
// os.TempDir
|
||||
// set the temp dir to outfolder
|
||||
// generate all the stuffs
|
||||
|
||||
// create a file in the tempdir folder named templates_test.go
|
||||
// use exec package to run go test in that folder (exec go test in that temp folder)
|
||||
|
||||
// when i use the exec theres a special thing. if i look here https://golang.org/pkg/os/exec/#Cmd
|
||||
// stderr (create bytes.buf, shove it into that) (use Command for initialization of obj)
|
||||
// use Run (not start) on the command. run the thing which will give an error
|
||||
// check that error, if its nil it completed successfully and test should pass
|
||||
// if not nil, compile failed. check stderr and pump it out and fail test.
|
||||
//
|
||||
// use Dir to set working dir of test.
|
||||
// ALWAYs REMBerR To DEFerR DleELtEE The FOoFldER
|
||||
// miGtihtr WaNnaAu leAVae around iwhen testing
|
||||
|
||||
func TestTemplates(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.SkipNow()
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
var testHeader = `package main
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@ var testColumns = []dbdrivers.DBColumn{
|
|||
}
|
||||
|
||||
func TestTitleCase(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
In string
|
||||
Out string
|
||||
|
@ -29,6 +31,8 @@ func TestTitleCase(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCamelCase(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
In string
|
||||
Out string
|
||||
|
@ -46,12 +50,16 @@ func TestCamelCase(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestMakeDBName(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
if out := makeDBName("a", "b"); out != "a_b" {
|
||||
t.Error("Out was wrong:", out)
|
||||
}
|
||||
}
|
||||
|
||||
func TestInsertParamNames(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
out := insertParamNames(testColumns)
|
||||
if out != "friend_column, enemy_column_thing" {
|
||||
t.Error("Wrong output:", out)
|
||||
|
@ -59,6 +67,8 @@ func TestInsertParamNames(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestInsertParamFlags(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
out := insertParamFlags(testColumns)
|
||||
if out != "$1, $2" {
|
||||
t.Error("Wrong output:", out)
|
||||
|
@ -66,6 +76,8 @@ func TestInsertParamFlags(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSelectParamFlags(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
out := selectParamNames("table", testColumns)
|
||||
if out != "friend_column AS table_friend_column, enemy_column_thing AS table_enemy_column_thing" {
|
||||
t.Error("Wrong output:", out)
|
||||
|
@ -73,6 +85,8 @@ func TestSelectParamFlags(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestScanParams(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
out := scanParamNames("object", testColumns)
|
||||
if out != "&object.FriendColumn, &object.EnemyColumnThing" {
|
||||
t.Error("Wrong output:", out)
|
||||
|
|
Loading…
Reference in a new issue