Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
fix builds and add extension tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rymurr committed Jan 10, 2025
1 parent 213f464 commit 8beef70
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 8 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/deps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
- name: "Run tests"
env:
DYLD_LIBRARY_PATH: deps/darwin_amd64
run: go test ./ -run '^TestOpen$' duckdb_test.go
run: go test ./ -run '^(TestOpen|TestExtensions)$' duckdb_test.go
- uses: actions/upload-artifact@v4
with:
name: darwin_amd64
Expand Down Expand Up @@ -107,7 +107,7 @@ jobs:
- name: "Run tests"
env:
DYLD_LIBRARY_PATH: deps/darwin_arm64
run: go test ./ -run '^TestOpen$' duckdb_test.go
run: go test ./ -run '^(TestOpen|TestExtensions)$' duckdb_test.go
- uses: actions/upload-artifact@v4
with:
name: darwin_arm64
Expand Down Expand Up @@ -144,7 +144,7 @@ jobs:
- name: "Run tests"
env:
LD_LIBRARY_PATH: deps/linux_amd64
run: go test ./ -run '^TestOpen$' duckdb_test.go
run: go test ./ -run '^(TestOpen|TestExtensions)$' duckdb_test.go
- uses: actions/upload-artifact@v4
with:
name: linux_amd64
Expand Down Expand Up @@ -198,7 +198,7 @@ jobs:
CXX: aarch64-linux-gnu-gcc
GOOS: linux
GOARCH: arm64
run: go test ./ -run '^TestOpen$' duckdb_test.go
run: go test ./ -run '^(TestOpen|TestExtensions)$' duckdb_test.go
- uses: actions/upload-artifact@v4
with:
name: linux_arm64
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ jobs:
go-version: ${{ matrix.go }}
- name: "Run tests"
env:
DYLD_LIBRARY_PATH: deps/darwin_amd64
LD_LIBRARY_PATH: deps/darwin_amd64
DYLD_LIBRARY_PATH: deps/darwin_arm64
LD_LIBRARY_PATH: deps/linux_amd64
run: make test
- uses: actions/upload-artifact@v4
with:
Expand All @@ -58,7 +58,7 @@ jobs:
go-version: ${{ matrix.go }}
- name: "Test examples"
env:
DYLD_LIBRARY_PATH: deps/darwin_amd64
LD_LIBRARY_PATH: deps/darwin_amd64
DYLD_LIBRARY_PATH: deps/darwin_arm64
LD_LIBRARY_PATH: deps/linux_amd64
run: make examples

31 changes: 31 additions & 0 deletions duckdb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,37 @@ func TestOpen(t *testing.T) {
})
}

func TestExtensions(t *testing.T) {
t.Parallel()

t.Run("with config", func(t *testing.T) {
db, err := sql.Open("duckdb", "?access_mode=read_write&threads=4")
require.NoError(t, err)
defer db.Close()

var (
substrait string
ak any
sk any
st any
r any
sz int
)
res := db.QueryRow("call get_substrait('select 1')")
require.NoError(t, res.Scan(&substrait))
require.Equal(t, "\x1a\x1b\x12\x19\n\x14:\x12\x12\n\n\b*\x06\n\x04\n\x02(*\x1a\x04\n\x02(\x01\x12\x0112\n\x105*\x06DuckDB", substrait)
res = db.QueryRow("call load_aws_credentials('foo')")
require.NoError(t, res.Scan(&ak, &sk, &st, &r))
// dont check the actual values, just check that there is no error
res = db.QueryRow("SELECT count(*) FROM 'https://localhost/file.parquet'")
err = res.Scan(&sz)
require.ErrorContains(t, err, "IO Error: Could not establish connection")
res = db.QueryRow("SELECT count(*) FROM iceberg_scan('data/iceberg/lineitem_iceberg', allow_moved_paths = true);")
err = res.Scan(&sz)
require.ErrorContains(t, err, "IO Error: Cannot open \"data/iceberg/lineitem_iceberg\"")
})
}

func TestConnectorBootQueries(t *testing.T) {
t.Run("readme example", func(t *testing.T) {
db, err := sql.Open("duckdb", "foo.db")
Expand Down

0 comments on commit 8beef70

Please sign in to comment.