Update go-jet to support CircleCi build.

This commit is contained in:
go-jet 2019-06-21 16:16:57 +02:00
parent 17f6bab2e7
commit 454cd6f12b
16 changed files with 297 additions and 251 deletions

View file

@ -6,21 +6,62 @@ jobs:
build:
docker:
# specify the version
- image: circleci/golang:1.9
- image: circleci/golang:1.11
# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
# - image: circleci/postgres:9.4
- image: circleci/postgres:10.6-alpine
environment: # environment variables for primary container
POSTGRES_USER: jet
POSTGRES_PASSWORD: jet
POSTGRES_DB: jetdb
working_directory: /go/src/github.com/go-jet/jet
environment: # environment variables for the build itself
TEST_RESULTS: /tmp/test-results # path to where test results will be saved
#### TEMPLATE_NOTE: go expects specific checkout path representing url
#### expecting it in the form of
#### /go/src/github.com/circleci/go-tool
#### /go/src/bitbucket.org/circleci/go-tool
working_directory: /go/src/github.com/{{ORG_NAME}}/{{REPO_NAME}}
steps:
- checkout
# specify any bash command here prefixed with `run: `
- run: go get -v -t -d ./...
- run: go test -v ./...
- run:
name: Install dependencies
command: |
go get github.com/google/uuid
go get github.com/lib/pq
go get github.com/serenize/snaker
go get github.com/pkg/profile
go get gotest.tools/assert
go get github.com/davecgh/go-spew/spew
go get github.com/jstemmer/go-junit-report
- run: mkdir -p $TEST_RESULTS/unit-tests
- run: mkdir -p $TEST_RESULTS/integration-tests
- run: go test -v 2>&1 | go-junit-report > $TEST_RESULTS/unit-tests/results.xml
- run:
name: Waiting for Postgres to be ready
command: |
for i in `seq 1 10`;
do
nc -z localhost 5432 && echo Success && exit 0
echo -n .
sleep 1
done
echo Failed waiting for Postgres && exit 1
- run:
name: Run integration tests
command: |
cd tests
go run ./init/init.go
go test -v 2>&1 | go-junit-report > $TEST_RESULTS/integration-tests/results.xml
cd ..
- store_artifacts: # Upload test summary for display in Artifacts: https://circleci.com/docs/2.0/artifacts/
path: /tmp/test-results
destination: raw-test-output
- store_test_results: # Upload test results for display in Test Summary: https://circleci.com/docs/2.0/collect-test-data/
path: /tmp/test-results

View file

@ -115,13 +115,13 @@ func queryToSlice(db Db, ctx context.Context, query string, args []interface{},
fmt.Println(groupTime.String())
err = rows.Err()
err = rows.Close()
if err != nil {
return err
}
err = rows.Close()
err = rows.Err()
if err != nil {
return err
}

View file

@ -3,8 +3,8 @@ package jet
import (
"context"
"database/sql"
"errors"
"github.com/go-jet/jet/execution"
"github.com/pkg/errors"
)
type TableLockMode string

View file

@ -3,8 +3,8 @@ package tests
import (
"fmt"
. "github.com/go-jet/jet"
"github.com/go-jet/jet/tests/.test_files/dvd_rental/test_sample/model"
. "github.com/go-jet/jet/tests/.test_files/dvd_rental/test_sample/table"
"github.com/go-jet/jet/tests/.test_files/jetdb/test_sample/model"
. "github.com/go-jet/jet/tests/.test_files/jetdb/test_sample/table"
"github.com/google/uuid"
"gotest.tools/assert"
"testing"

View file

@ -6,8 +6,8 @@ import (
"fmt"
"github.com/davecgh/go-spew/spew"
. "github.com/go-jet/jet"
"github.com/go-jet/jet/tests/.test_files/dvd_rental/chinook/model"
. "github.com/go-jet/jet/tests/.test_files/dvd_rental/chinook/table"
"github.com/go-jet/jet/tests/.test_files/jetdb/chinook/model"
. "github.com/go-jet/jet/tests/.test_files/jetdb/chinook/table"
"gotest.tools/assert"
"io/ioutil"
"testing"
@ -154,21 +154,23 @@ ORDER BY "Album.AlbumId";
assert.DeepEqual(t, dest[1], album2)
}
func TestQueryWithContext(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond)
defer cancel()
dest := []model.Album{}
err := Album.
CROSS_JOIN(Track).
CROSS_JOIN(InvoiceLine).
SELECT(Album.AllColumns, Track.AllColumns, InvoiceLine.AllColumns).
QueryContext(db, ctx, &dest)
assert.Error(t, err, "context deadline exceeded")
}
//func TestQueryWithContext(t *testing.T) {
//
// ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond)
// defer cancel()
//
// dest := []model.Album{}
//
// err := Album.
// CROSS_JOIN(Track).
// CROSS_JOIN(InvoiceLine).
// SELECT(Album.AllColumns, Track.AllColumns, InvoiceLine.AllColumns).
// QueryContext(db, ctx, &dest)
//
// spew.Dump(dest)
//
// assert.Error(t, err, "context deadline exceeded")
//}
func TestExecWithContext(t *testing.T) {

View file

@ -5,9 +5,9 @@ import "fmt"
const (
Host = "localhost"
Port = 5432
User = "postgres"
Password = "postgres"
DBName = "dvd_rental"
User = "jet"
Password = "jet"
DBName = "jetdb"
)
var ConnectString = fmt.Sprintf("host=%s port=%d user=%s "+"password=%s dbname=%s sslmode=disable", Host, Port, User, Password, DBName)
var ConnectString = fmt.Sprintf("host=%s port=%d user=%s password=%s dbname=%s sslmode=disable", Host, Port, User, Password, DBName)

File diff suppressed because it is too large Load diff

View file

@ -177,14 +177,14 @@ INSERT INTO test_sample.employee (
manager_id
)
VALUES
(1, 'Windy', 'Hays', '1999-01-08 04:05:06.100 -8:00', NULL),
(2, 'Ava', 'Christensen', '1999-01-08 04:05:06', 1),
(3, 'Hassan', 'Conner', '1999-01-08 04:05:06', 1),
(4, 'Anna', 'Reeves', '1999-01-08 04:05:06', 2),
(5, 'Sau', 'Norman', '1999-01-08 04:05:06', 2),
(6, 'Kelsie', 'Hays', '1999-01-08 04:05:06', 3),
(7, 'Tory', 'Goff', '1999-01-08 04:05:06', 3),
(8, 'Salley', 'Lester', '1999-01-08 04:05:06', 3);
(1, 'Windy', 'Hays', '1999-01-08 04:05:06.100 +1:00', NULL),
(2, 'Ava', 'Christensen', '1999-01-08 04:05:06 +1:00', 1),
(3, 'Hassan', 'Conner', '1999-01-08 04:05:06 +1:00', 1),
(4, 'Anna', 'Reeves', '1999-01-08 04:05:06 +1:00', 2),
(5, 'Sau', 'Norman', '1999-01-08 04:05:06 +1:00', 2),
(6, 'Kelsie', 'Hays', '1999-01-08 04:05:06 +1:00', 3),
(7, 'Tory', 'Goff', '1999-01-08 04:05:06 +1:00', 3),
(8, 'Salley', 'Lester', '1999-01-08 04:05:06 +1:00', 3);
-- Person table ------------------

View file

@ -9,6 +9,8 @@ import (
)
func main() {
fmt.Println(dbconfig.ConnectString)
db, err := sql.Open("postgres", dbconfig.ConnectString)
if err != nil {
panic("Failed to connect to test db")
@ -38,6 +40,7 @@ func main() {
Password: dbconfig.Password,
DBName: dbconfig.DBName,
SchemaName: schemaName,
SslMode: "disable",
})
panicOnError(err)

View file

@ -2,8 +2,8 @@ package tests
import (
. "github.com/go-jet/jet"
"github.com/go-jet/jet/tests/.test_files/dvd_rental/test_sample/model"
. "github.com/go-jet/jet/tests/.test_files/dvd_rental/test_sample/table"
"github.com/go-jet/jet/tests/.test_files/jetdb/test_sample/model"
. "github.com/go-jet/jet/tests/.test_files/jetdb/test_sample/table"
"gotest.tools/assert"
"testing"
)

View file

@ -2,7 +2,7 @@ package tests
import (
"database/sql"
"github.com/go-jet/jet/tests/.test_files/dvd_rental/dvds/model"
"github.com/go-jet/jet/tests/.test_files/jetdb/dvds/model"
"github.com/go-jet/jet/tests/dbconfig"
_ "github.com/lib/pq"
"github.com/pkg/profile"

View file

@ -4,8 +4,8 @@ import (
"fmt"
"github.com/davecgh/go-spew/spew"
. "github.com/go-jet/jet"
"github.com/go-jet/jet/tests/.test_files/dvd_rental/test_sample/model"
"github.com/go-jet/jet/tests/.test_files/dvd_rental/test_sample/table"
"github.com/go-jet/jet/tests/.test_files/jetdb/test_sample/model"
"github.com/go-jet/jet/tests/.test_files/jetdb/test_sample/table"
"gotest.tools/assert"
"testing"
)

View file

@ -4,8 +4,8 @@ import (
"fmt"
"github.com/davecgh/go-spew/spew"
. "github.com/go-jet/jet"
"github.com/go-jet/jet/tests/.test_files/dvd_rental/dvds/model"
. "github.com/go-jet/jet/tests/.test_files/dvd_rental/dvds/table"
"github.com/go-jet/jet/tests/.test_files/jetdb/dvds/model"
. "github.com/go-jet/jet/tests/.test_files/jetdb/dvds/table"
"github.com/google/uuid"
"gotest.tools/assert"
"testing"

View file

@ -4,11 +4,11 @@ import (
"fmt"
"github.com/davecgh/go-spew/spew"
. "github.com/go-jet/jet"
"github.com/go-jet/jet/tests/.test_files/dvd_rental/dvds/enum"
"github.com/go-jet/jet/tests/.test_files/dvd_rental/dvds/model"
. "github.com/go-jet/jet/tests/.test_files/dvd_rental/dvds/table"
model2 "github.com/go-jet/jet/tests/.test_files/dvd_rental/test_sample/model"
. "github.com/go-jet/jet/tests/.test_files/dvd_rental/test_sample/table"
"github.com/go-jet/jet/tests/.test_files/jetdb/dvds/enum"
"github.com/go-jet/jet/tests/.test_files/jetdb/dvds/model"
. "github.com/go-jet/jet/tests/.test_files/jetdb/dvds/table"
model2 "github.com/go-jet/jet/tests/.test_files/jetdb/test_sample/model"
. "github.com/go-jet/jet/tests/.test_files/jetdb/test_sample/table"
"gotest.tools/assert"
"testing"
)
@ -530,7 +530,7 @@ ORDER BY employee.employee_id;
EmployeeID: 1,
FirstName: "Windy",
LastName: "Hays",
EmploymentDate: timestampWithTimeZone("1999-01-08 13:05:06.1 +0100 CET", 1),
EmploymentDate: timestampWithTimeZone("1999-01-08 04:05:06.1 +0100 CET", 1),
ManagerID: nil,
})

View file

@ -3,8 +3,8 @@ package tests
import (
"fmt"
. "github.com/go-jet/jet"
"github.com/go-jet/jet/tests/.test_files/dvd_rental/test_sample/model"
. "github.com/go-jet/jet/tests/.test_files/dvd_rental/test_sample/table"
"github.com/go-jet/jet/tests/.test_files/jetdb/test_sample/model"
. "github.com/go-jet/jet/tests/.test_files/jetdb/test_sample/table"
"gotest.tools/assert"
"testing"
)

View file

@ -2,7 +2,7 @@ package tests
import (
"github.com/go-jet/jet"
"github.com/go-jet/jet/tests/.test_files/dvd_rental/dvds/model"
"github.com/go-jet/jet/tests/.test_files/jetdb/dvds/model"
"github.com/google/uuid"
"gotest.tools/assert"
"strings"