Update CircleCI to support MySQL

This commit is contained in:
go-jet 2019-08-08 12:02:32 +02:00
parent f9b900b303
commit 0ab25e4464
28 changed files with 198 additions and 240 deletions

View file

@ -1,13 +0,0 @@
package snaker
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"testing"
)
func TestDb(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Snaker Suite")
}

View file

@ -1,40 +1,16 @@
package snaker
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"gotest.tools/assert"
"testing"
)
var _ = Describe("Snaker", func() {
Describe("SnakeToCamel test", func() {
It("should return an empty string on an empty input", func() {
Expect(SnakeToCamel("")).To(Equal(""))
})
It("should not blow up on trailing _", func() {
Expect(SnakeToCamel("potato_")).To(Equal("Potato"))
})
It("should return a snaked text as camel case", func() {
Expect(SnakeToCamel("this_has_to_be_uppercased")).To(
Equal("ThisHasToBeUppercased"))
})
It("should return a snaked text as camel case, except the word ID", func() {
Expect(SnakeToCamel("this_is_an_id")).To(Equal("ThisIsAnID"))
})
It("should return 'id' not as uppercase", func() {
Expect(SnakeToCamel("this_is_an_identifier")).To(Equal("ThisIsAnIdentifier"))
})
It("should simply work with id", func() {
Expect(SnakeToCamel("id")).To(Equal("ID"))
})
It("should work with initialism where only certain characters are uppercase", func() {
Expect(SnakeToCamel("oauth_client")).To(Equal("OAuthClient"))
})
})
})
func TestSnakeToCamel(t *testing.T) {
assert.Equal(t, SnakeToCamel(""), "")
assert.Equal(t, SnakeToCamel("potato_"), "Potato")
assert.Equal(t, SnakeToCamel("this_has_to_be_uppercased"), "ThisHasToBeUppercased")
assert.Equal(t, SnakeToCamel("this_is_an_id"), "ThisIsAnID")
assert.Equal(t, SnakeToCamel("this_is_an_identifier"), "ThisIsAnIdentifier")
assert.Equal(t, SnakeToCamel("id"), "ID")
assert.Equal(t, SnakeToCamel("oauth_client"), "OAuthClient")
}

View file

@ -51,6 +51,25 @@ func (t *timestampzInterfaceImpl) GT_EQ(rhs TimestampzExpression) BoolExpression
return gtEq(t.parent, rhs)
}
//---------------------------------------------------//
type prefixTimestampzOperator struct {
expressionInterfaceImpl
timestampzInterfaceImpl
prefixOpExpression
}
func NewPrefixTimestampOperator(operator string, expression Expression) TimestampzExpression {
timeExpr := prefixTimestampzOperator{}
timeExpr.prefixOpExpression = newPrefixExpression(expression, operator)
timeExpr.expressionInterfaceImpl.parent = &timeExpr
timeExpr.timestampzInterfaceImpl.parent = &timeExpr
return &timeExpr
}
//-------------------------------------------------
type timestampzExpressionWrapper struct {

View file

@ -1,6 +1,7 @@
package utils
import (
"database/sql"
"github.com/go-jet/jet/internal/3rdparty/snaker"
"go/format"
"os"
@ -79,6 +80,14 @@ func CleanUpGeneratedFiles(dir string) error {
return nil
}
func DBClose(db *sql.DB) {
if db == nil {
return
}
db.Close()
}
// DirExists checks if folder at path exist.
func DirExists(path string) (bool, error) {
_, err := os.Stat(path)