File tree Expand file tree Collapse file tree 4 files changed +80
-1
lines changed
Expand file tree Collapse file tree 4 files changed +80
-1
lines changed Original file line number Diff line number Diff line change 1- name : Go
1+ name : CI
22
33on :
44 push :
1919 uses : golangci/golangci-lint-action@v2
2020 with :
2121 version : v1.48
22+
23+ integration :
24+ permissions :
25+ contents : read
26+ packages : read
27+ name : Integration Tests
28+ strategy :
29+ matrix :
30+ go-version : [1.19.x]
31+ os : [ubuntu-latest]
32+ runs-on : ${{ matrix.os }}
33+ services :
34+ test-server :
35+ options : --user "appuser"
36+ credentials :
37+ username : ${{ github.repository }}
38+ password : ${{ secrets.GITHUB_TOKEN }}
39+ image : ghcr.io/databricks/databricks/databricks-thrift-test-server:main
40+ ports :
41+ - 8087:8087
42+ steps :
43+ - name : Check out code into the Go module directory
44+ uses : actions/checkout@v3
45+
46+ - name : Set up Go Toolchain
47+ uses : actions/setup-go@v3
48+ with :
49+ go-version : ${{ matrix.go-version }}
50+
51+ - name : Cache Go artifacts
52+ uses : actions/cache@v2
53+ with :
54+ path : |
55+ ~/go/pkg/mod
56+ ~/.cache/go-build
57+ key : ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
58+ restore-keys : |
59+ ${{ runner.os }}-go-${{ matrix.go-version }}-
60+
61+
62+ - name : run integration tests
63+ run : make test-integration
64+
2265 build-and-test :
2366 name : Test and Build
2467 strategy :
Original file line number Diff line number Diff line change @@ -57,6 +57,12 @@ test: bin/gotestsum ## Run the go unit tests.
5757 @echo " INFO: Running all go unit tests."
5858 CGO_ENABLED=0 ./bin/gotestsum --format pkgname-and-test-fails --junitfile $(TEST_RESULTS_DIR ) /unit-tests.xml ./...
5959
60+ .PHONY : test-integration
61+ test-integration : bin/gotestsum # # Run the go unit integration tests.
62+ @echo " INFO: Running all go integration tests."
63+ CGO_ENABLED=0 ./bin/gotestsum --format pkgname-and-test-fails -- -tags=integration ./...
64+
65+
6066.PHONY : coverage
6167coverage : bin/gotestsum # # Report the unit test code coverage.
6268 @echo " INFO: Generating unit test coverage report."
Original file line number Diff line number Diff line change 1+ package integration_tests
Original file line number Diff line number Diff line change 1+ //go:build integration
2+
3+ package integration_tests
4+
5+ import (
6+ "context"
7+ "database/sql"
8+ "testing"
9+
10+ dbsql "github.com/databricks/databricks-sql-go"
11+ "github.com/stretchr/testify/require"
12+ )
13+
14+ func TestIntegrationPing (t * testing.T ) {
15+
16+ connector , err := dbsql .NewConnector (
17+ dbsql .WithServerHostname ("localhost" ),
18+ dbsql .WithPort (8087 ),
19+ )
20+ require .NoError (t , err )
21+ db := sql .OpenDB (connector )
22+ defer db .Close ()
23+
24+ t .Run ("it can ping" , func (t * testing.T ) {
25+ if err := db .PingContext (context .Background ()); err != nil {
26+ require .NoError (t , err )
27+ }
28+ })
29+ }
You can’t perform that action at this time.
0 commit comments