diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 00000000..50a8d80d --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,26 @@ +name: Go +on: + push: + branches: # Array of patterns that match refs/heads + - master # Push events on master branch + - releases/* # Push events to branches matching refs/heads/releases/* + pull_request: # Specify a second event with pattern matching +jobs: + test: + name: Test go ${{ matrix.go_version }} + runs-on: ubuntu-latest + strategy: + matrix: + go_version: ["1.10", "1.11", "latest"] + steps: + - name: checkout + uses: actions/checkout@v1 + - name: Test + env: + GO_VERSION: ${{ matrix.go_version }} + run: docker-compose run goqu-coverage + - name: Upload coverage to Codecov + run: bash <(curl -s https://codecov.io/bash) -n $GO_VERSION -e GO_VERSION,GITHUB_WORKFLOW,GITHUB_ACTION + env: + CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}} + GO_VERSION: ${{ matrix.go_version }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 272a69fa..00000000 --- a/.travis.yml +++ /dev/null @@ -1,21 +0,0 @@ -sudo: true -language: go -services: - - docker - -go_import_path: github.com/doug-martin/goqu - -env: - - GO_VERSION="1.10" - - GO_VERSION="1.11" - - GO_VERSION="latest" - -before_install: - - curl -L https://github.com/docker/compose/releases/download/1.8.1/docker-compose-`uname -s`-`uname -m` > docker-compose - - chmod +x docker-compose - - sudo mv docker-compose /usr/local/bin - -script: docker-compose run goqu-coverage - -after_success: - - bash <(curl -s https://codecov.io/bash) diff --git a/goqu_test.go b/goqu_test.go new file mode 100644 index 00000000..83a85e9b --- /dev/null +++ b/goqu_test.go @@ -0,0 +1,60 @@ +package goqu + +import ( + "testing" + + "github.com/DATA-DOG/go-sqlmock" + "github.com/stretchr/testify/suite" +) + +type ( + dialectWrapperSuite struct { + suite.Suite + } +) + +func (dws *dialectWrapperSuite) SetupSuite() { + testDialect := DefaultDialectOptions() + // override to some value to ensure correct dialect is set + RegisterDialect("test", testDialect) +} + +func (dws *dialectWrapperSuite) TearDownSuite() { + DeregisterDialect("test") +} + +func (dws *dialectWrapperSuite) TestFrom() { + dw := Dialect("test") + dws.Equal(From("table").WithDialect("test"), dw.From("table")) +} + +func (dws *dialectWrapperSuite) TestSelect() { + dw := Dialect("test") + dws.Equal(Select("col").WithDialect("test"), dw.Select("col")) +} + +func (dws *dialectWrapperSuite) TestInsert() { + dw := Dialect("test") + dws.Equal(Insert("table").WithDialect("test"), dw.Insert("table")) +} + +func (dws *dialectWrapperSuite) TestDelete() { + dw := Dialect("test") + dws.Equal(Delete("table").WithDialect("test"), dw.Delete("table")) +} + +func (dws *dialectWrapperSuite) TestTruncate() { + dw := Dialect("test") + dws.Equal(Truncate("table").WithDialect("test"), dw.Truncate("table")) +} + +func (dws *dialectWrapperSuite) TestDB() { + mDb, _, err := sqlmock.New() + dws.Require().NoError(err) + dw := Dialect("test") + dws.Equal(New("test", mDb), dw.DB(mDb)) +} + +func TestDialectWrapper(t *testing.T) { + suite.Run(t, new(dialectWrapperSuite)) +}