From 7d735957ca58b7c52815912057e4707cec66923b Mon Sep 17 00:00:00 2001 From: Bryce Mecum Date: Tue, 16 Dec 2025 16:41:48 -0800 Subject: [PATCH 01/11] Set up full user/system tests --- .github/workflows/go.yml | 2 +- cmd/dbc/integration_test.go | 75 +++++++++++++++++++++++++++++ cmd/dbc/integration_test_unix.go | 28 +++++++++++ cmd/dbc/integration_test_windows.go | 40 +++++++++++++++ config/config.go | 5 ++ 5 files changed, 149 insertions(+), 1 deletion(-) create mode 100644 cmd/dbc/integration_test.go create mode 100644 cmd/dbc/integration_test_unix.go create mode 100644 cmd/dbc/integration_test_windows.go diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 0d602e3..c598974 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -58,4 +58,4 @@ jobs: - name: Run Tests # the file with `test_registry` also requires windows, so we can safely add this tag # without it running on non-windows OSes - run: go test -v -tags test_registry ./... + run: go test -v -tags test_registry,test_integration ./... diff --git a/cmd/dbc/integration_test.go b/cmd/dbc/integration_test.go new file mode 100644 index 0000000..a80dacb --- /dev/null +++ b/cmd/dbc/integration_test.go @@ -0,0 +1,75 @@ +// Copyright 2025 Columnar Technologies Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build test_integration + +package main + +import ( + "bytes" + "context" + "testing" + "time" + + tea "github.com/charmbracelet/bubbletea" + "github.com/columnar-tech/dbc/config" + "github.com/stretchr/testify/suite" +) + +type IntegrationTestSuite struct { + suite.Suite +} + +func (s *IntegrationTestSuite) run(m tea.Model) string { + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + + var out bytes.Buffer + p := tea.NewProgram(m, tea.WithInput(nil), tea.WithOutput(&out), + tea.WithContext(ctx), tea.WithoutRenderer()) + + var err error + m, err = p.Run() + s.Require().NoError(err) + s.Equal(0, m.(HasStatus).Status(), "exited with a non-zero status") + + var extra string + if fo, ok := m.(HasFinalOutput); ok { + extra = fo.FinalOutput() + } + return out.String() + extra +} + +// This test suite only runs when the "test_integration" build tag is set. These +// tests are intended to only be run in VMs or on CI because they may modify +// user and system files and the Windows registry. +func TestIntegration(t *testing.T) { + suite.Run(t, new(IntegrationTestSuite)) +} + +func (suite *IntegrationTestSuite) TestInstallUser() { + m := InstallCmd{Driver: "test-driver-1", Level: config.ConfigUser}. + GetModelCustom(baseModel{getDriverRegistry: getTestDriverRegistry, downloadPkg: downloadTestPkg}) + out := suite.run(m) + // TODO: Assert driver is installed + suite.Equal("foo", out) +} + +func (suite *IntegrationTestSuite) TestInstallSystem() { + m := InstallCmd{Driver: "test-driver-1", Level: config.ConfigSystem}. + GetModelCustom(baseModel{getDriverRegistry: getTestDriverRegistry, downloadPkg: downloadTestPkg}) + out := suite.run(m) + // TODO: Assert driver is installed + suite.Equal("foo", out) +} diff --git a/cmd/dbc/integration_test_unix.go b/cmd/dbc/integration_test_unix.go new file mode 100644 index 0000000..f26a706 --- /dev/null +++ b/cmd/dbc/integration_test_unix.go @@ -0,0 +1,28 @@ +// Copyright 2025 Columnar Technologies Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build test_integration && !windows + +package main + +import ( + "os" + + "github.com/columnar-tech/dbc/config" +) + +func (suite *IntegrationTestSuite) TearDownTest() { + os.RemoveAll(config.GetLocation(config.ConfigUser)) + os.RemoveAll(config.GetLocation(config.ConfigSystem)) +} diff --git a/cmd/dbc/integration_test_windows.go b/cmd/dbc/integration_test_windows.go new file mode 100644 index 0000000..cdaa8de --- /dev/null +++ b/cmd/dbc/integration_test_windows.go @@ -0,0 +1,40 @@ +// Copyright 2025 Columnar Technologies Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build test_integration && windows + +package main + +import ( + "os" + + "github.com/columnar-tech/dbc/config" + "golang.org/x/sys/windows/registry" +) + +func (suite *IntegrationTestSuite) TearDownTest() { + // Clean up the registry and filesystem between each test + // + // `regKeyADBC` isn't exported, we redefine it here + regKeyADBC := "SOFTWARE\\ADBC\\Drivers" + // We ignore registry errors. The `registry` package doesn't have a method to + // explicitly check key existence we could either check the error or just try + // and ignore + registry.DeleteKey(registry.CURRENT_USER, regKeyADBC) + registry.DeleteKey(registry.LOCAL_MACHINE, regKeyADBC) + + // Clean up filesystem + os.RemoveAll(config.GetLocation(config.ConfigUser)) + os.RemoveAll(config.GetLocation(config.ConfigSystem)) +} diff --git a/config/config.go b/config/config.go index 992143c..5094e67 100644 --- a/config/config.go +++ b/config/config.go @@ -97,6 +97,11 @@ func (c ConfigLevel) String() string { } } +// GetLocation returns the filesystem path for the given config level. +func GetLocation(level ConfigLevel) string { + return level.configLocation() +} + func (c *ConfigLevel) UnmarshalText(b []byte) error { switch strings.ToLower(strings.TrimSpace(string(b))) { case "system": From 7bb0b402b1af9b2016585712fadb6fdfcd20ddb0 Mon Sep 17 00:00:00 2001 From: Bryce Mecum Date: Tue, 16 Dec 2025 16:58:39 -0800 Subject: [PATCH 02/11] fill in tests --- cmd/dbc/integration_test.go | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/cmd/dbc/integration_test.go b/cmd/dbc/integration_test.go index a80dacb..ed5559b 100644 --- a/cmd/dbc/integration_test.go +++ b/cmd/dbc/integration_test.go @@ -19,6 +19,8 @@ package main import ( "bytes" "context" + "path/filepath" + "runtime" "testing" "time" @@ -62,14 +64,34 @@ func (suite *IntegrationTestSuite) TestInstallUser() { m := InstallCmd{Driver: "test-driver-1", Level: config.ConfigUser}. GetModelCustom(baseModel{getDriverRegistry: getTestDriverRegistry, downloadPkg: downloadTestPkg}) out := suite.run(m) - // TODO: Assert driver is installed - suite.Equal("foo", out) + loc := config.GetLocation(config.ConfigUser) + + suite.Equal("\nInstalled test-driver-1 1.1.0 to "+loc+"\n", out) + if runtime.GOOS == "windows" { + // Should fail + suite.FileExists(filepath.Join(loc, "test-driver-1.toml")) + } else { + suite.FileExists(filepath.Join(loc, "test-driver-1.toml")) + } + suite.FileExists(filepath.Join(loc, "test-driver-1", "test-driver-1-not-valid.so")) + suite.FileExists(filepath.Join(loc, "test-driver-1", "MANIFEST")) + suite.FileExists(filepath.Join(loc, "test-driver-1", "test-driver-1-not-valid.so.sig")) } func (suite *IntegrationTestSuite) TestInstallSystem() { m := InstallCmd{Driver: "test-driver-1", Level: config.ConfigSystem}. GetModelCustom(baseModel{getDriverRegistry: getTestDriverRegistry, downloadPkg: downloadTestPkg}) out := suite.run(m) - // TODO: Assert driver is installed - suite.Equal("foo", out) + loc := config.GetLocation(config.ConfigSystem) + + suite.Equal("\nInstalled test-driver-1 1.1.0 to "+loc+"\n", out) + if runtime.GOOS == "windows" { + // Should fail + suite.FileExists(filepath.Join(loc, "test-driver-1.toml")) + } else { + suite.FileExists(filepath.Join(loc, "test-driver-1.toml")) + } + suite.FileExists(filepath.Join(loc, "test-driver-1", "test-driver-1-not-valid.so")) + suite.FileExists(filepath.Join(loc, "test-driver-1", "MANIFEST")) + suite.FileExists(filepath.Join(loc, "test-driver-1", "test-driver-1-not-valid.so.sig")) } From 467a3aad67c4bf70e0f0c5a4615ada22490a6b2f Mon Sep 17 00:00:00 2001 From: Bryce Mecum Date: Tue, 16 Dec 2025 17:02:36 -0800 Subject: [PATCH 03/11] fix how tests are run in ci --- .github/workflows/go.yml | 12 +++++++++++- cmd/dbc/integration_test.go | 8 ++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index c598974..16b09df 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -58,4 +58,14 @@ jobs: - name: Run Tests # the file with `test_registry` also requires windows, so we can safely add this tag # without it running on non-windows OSes - run: go test -v -tags test_registry,test_integration ./... + run: go test -v -tags test_registry ./... + - name: Run Integration Tests (Unix) + if: runner.os != 'Windows' + env: + DBC_RUN_INTEGRATION_TESTS: 1 + run: sudo -E go test -v -tags test_integration ./cmd/dbc + - name: Run Integration Tests (Windows) + if: runner.os == 'Windows' + env: + DBC_RUN_INTEGRATION_TESTS: 1 + run: go test -v -tags test_integration ./cmd/dbc diff --git a/cmd/dbc/integration_test.go b/cmd/dbc/integration_test.go index ed5559b..acb3f43 100644 --- a/cmd/dbc/integration_test.go +++ b/cmd/dbc/integration_test.go @@ -19,6 +19,7 @@ package main import ( "bytes" "context" + "os" "path/filepath" "runtime" "testing" @@ -33,6 +34,13 @@ type IntegrationTestSuite struct { suite.Suite } +func (suite *IntegrationTestSuite) SetupSuite() { + // Integration tests require both the build tag AND environment variable + if os.Getenv("DBC_RUN_INTEGRATION_TESTS") == "" { + suite.T().Skip("Set DBC_RUN_INTEGRATION_TESTS=1 to run integration tests") + } +} + func (s *IntegrationTestSuite) run(m tea.Model) string { ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() From cf758560876b3d5c2e57165dc707fe6e0c6d1e09 Mon Sep 17 00:00:00 2001 From: Bryce Mecum Date: Tue, 16 Dec 2025 17:08:12 -0800 Subject: [PATCH 04/11] fix test --- cmd/dbc/integration_test.go | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/cmd/dbc/integration_test.go b/cmd/dbc/integration_test.go index acb3f43..6909f61 100644 --- a/cmd/dbc/integration_test.go +++ b/cmd/dbc/integration_test.go @@ -75,15 +75,13 @@ func (suite *IntegrationTestSuite) TestInstallUser() { loc := config.GetLocation(config.ConfigUser) suite.Equal("\nInstalled test-driver-1 1.1.0 to "+loc+"\n", out) - if runtime.GOOS == "windows" { - // Should fail + if runtime.GOOS != "windows" { suite.FileExists(filepath.Join(loc, "test-driver-1.toml")) } else { - suite.FileExists(filepath.Join(loc, "test-driver-1.toml")) + // TODO: Windows } - suite.FileExists(filepath.Join(loc, "test-driver-1", "test-driver-1-not-valid.so")) - suite.FileExists(filepath.Join(loc, "test-driver-1", "MANIFEST")) - suite.FileExists(filepath.Join(loc, "test-driver-1", "test-driver-1-not-valid.so.sig")) + suite.FileExists(filepath.Join(loc, "test-driver-1.1", "test-driver-1-not-valid.so")) + suite.FileExists(filepath.Join(loc, "test-driver-1.1", "test-driver-1-not-valid.so.sig")) } func (suite *IntegrationTestSuite) TestInstallSystem() { @@ -93,13 +91,11 @@ func (suite *IntegrationTestSuite) TestInstallSystem() { loc := config.GetLocation(config.ConfigSystem) suite.Equal("\nInstalled test-driver-1 1.1.0 to "+loc+"\n", out) - if runtime.GOOS == "windows" { - // Should fail + if runtime.GOOS != "windows" { suite.FileExists(filepath.Join(loc, "test-driver-1.toml")) } else { - suite.FileExists(filepath.Join(loc, "test-driver-1.toml")) + // TODO: Windows } - suite.FileExists(filepath.Join(loc, "test-driver-1", "test-driver-1-not-valid.so")) - suite.FileExists(filepath.Join(loc, "test-driver-1", "MANIFEST")) - suite.FileExists(filepath.Join(loc, "test-driver-1", "test-driver-1-not-valid.so.sig")) + suite.FileExists(filepath.Join(loc, "test-driver-1.1", "test-driver-1-not-valid.so")) + suite.FileExists(filepath.Join(loc, "test-driver-1.1", "test-driver-1-not-valid.so.sig")) } From 17304210ec2a3cac1008f0c22d2265b05365a905 Mon Sep 17 00:00:00 2001 From: Bryce Mecum Date: Tue, 16 Dec 2025 17:13:25 -0800 Subject: [PATCH 05/11] just run integration tests --- .github/workflows/go.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 16b09df..7266753 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -63,9 +63,9 @@ jobs: if: runner.os != 'Windows' env: DBC_RUN_INTEGRATION_TESTS: 1 - run: sudo -E go test -v -tags test_integration ./cmd/dbc + run: sudo -E go test -v -tags test_integration -run TestIntegration ./cmd/dbc - name: Run Integration Tests (Windows) if: runner.os == 'Windows' env: DBC_RUN_INTEGRATION_TESTS: 1 - run: go test -v -tags test_integration ./cmd/dbc + run: go test -v -tags test_integration -run TestIntegration ./cmd/dbc From 3497c0356bc190607c6654ce3ed170e8dc46aa06 Mon Sep 17 00:00:00 2001 From: Bryce Mecum Date: Tue, 16 Dec 2025 17:15:48 -0800 Subject: [PATCH 06/11] check registry on windows --- cmd/dbc/integration_test.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cmd/dbc/integration_test.go b/cmd/dbc/integration_test.go index 6909f61..6a4a654 100644 --- a/cmd/dbc/integration_test.go +++ b/cmd/dbc/integration_test.go @@ -28,6 +28,7 @@ import ( tea "github.com/charmbracelet/bubbletea" "github.com/columnar-tech/dbc/config" "github.com/stretchr/testify/suite" + "golang.org/x/sys/windows/registry" ) type IntegrationTestSuite struct { @@ -78,7 +79,9 @@ func (suite *IntegrationTestSuite) TestInstallUser() { if runtime.GOOS != "windows" { suite.FileExists(filepath.Join(loc, "test-driver-1.toml")) } else { - // TODO: Windows + k, err := registry.OpenKey(registry.CURRENT_USER, `SOFTWARE\ADBC\Drivers\test-driver-1`, registry.QUERY_VALUE) + suite.Require().NoError(err, "registry key should exist") + defer k.Close() } suite.FileExists(filepath.Join(loc, "test-driver-1.1", "test-driver-1-not-valid.so")) suite.FileExists(filepath.Join(loc, "test-driver-1.1", "test-driver-1-not-valid.so.sig")) @@ -94,7 +97,9 @@ func (suite *IntegrationTestSuite) TestInstallSystem() { if runtime.GOOS != "windows" { suite.FileExists(filepath.Join(loc, "test-driver-1.toml")) } else { - // TODO: Windows + k, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\ADBC\Drivers\test-driver-1`, registry.QUERY_VALUE) + suite.Require().NoError(err, "registry key should exist") + defer k.Close() } suite.FileExists(filepath.Join(loc, "test-driver-1.1", "test-driver-1-not-valid.so")) suite.FileExists(filepath.Join(loc, "test-driver-1.1", "test-driver-1-not-valid.so.sig")) From f3647380ef68b23a78e4ff9650c10fc38147066a Mon Sep 17 00:00:00 2001 From: Bryce Mecum Date: Tue, 16 Dec 2025 17:19:35 -0800 Subject: [PATCH 07/11] refactor --- cmd/dbc/integration_test.go | 18 ++---------------- cmd/dbc/integration_test_unix.go | 6 ++++++ cmd/dbc/integration_test_windows.go | 14 ++++++++++++++ 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/cmd/dbc/integration_test.go b/cmd/dbc/integration_test.go index 6a4a654..0d1be6c 100644 --- a/cmd/dbc/integration_test.go +++ b/cmd/dbc/integration_test.go @@ -21,14 +21,12 @@ import ( "context" "os" "path/filepath" - "runtime" "testing" "time" tea "github.com/charmbracelet/bubbletea" "github.com/columnar-tech/dbc/config" "github.com/stretchr/testify/suite" - "golang.org/x/sys/windows/registry" ) type IntegrationTestSuite struct { @@ -76,13 +74,7 @@ func (suite *IntegrationTestSuite) TestInstallUser() { loc := config.GetLocation(config.ConfigUser) suite.Equal("\nInstalled test-driver-1 1.1.0 to "+loc+"\n", out) - if runtime.GOOS != "windows" { - suite.FileExists(filepath.Join(loc, "test-driver-1.toml")) - } else { - k, err := registry.OpenKey(registry.CURRENT_USER, `SOFTWARE\ADBC\Drivers\test-driver-1`, registry.QUERY_VALUE) - suite.Require().NoError(err, "registry key should exist") - defer k.Close() - } + suite.driverIsInstalled("test-driver-1", config.ConfigUser) suite.FileExists(filepath.Join(loc, "test-driver-1.1", "test-driver-1-not-valid.so")) suite.FileExists(filepath.Join(loc, "test-driver-1.1", "test-driver-1-not-valid.so.sig")) } @@ -94,13 +86,7 @@ func (suite *IntegrationTestSuite) TestInstallSystem() { loc := config.GetLocation(config.ConfigSystem) suite.Equal("\nInstalled test-driver-1 1.1.0 to "+loc+"\n", out) - if runtime.GOOS != "windows" { - suite.FileExists(filepath.Join(loc, "test-driver-1.toml")) - } else { - k, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\ADBC\Drivers\test-driver-1`, registry.QUERY_VALUE) - suite.Require().NoError(err, "registry key should exist") - defer k.Close() - } + suite.driverIsInstalled("test-driver-1", config.ConfigSystem) suite.FileExists(filepath.Join(loc, "test-driver-1.1", "test-driver-1-not-valid.so")) suite.FileExists(filepath.Join(loc, "test-driver-1.1", "test-driver-1-not-valid.so.sig")) } diff --git a/cmd/dbc/integration_test_unix.go b/cmd/dbc/integration_test_unix.go index f26a706..821d43f 100644 --- a/cmd/dbc/integration_test_unix.go +++ b/cmd/dbc/integration_test_unix.go @@ -18,6 +18,7 @@ package main import ( "os" + "path/filepath" "github.com/columnar-tech/dbc/config" ) @@ -26,3 +27,8 @@ func (suite *IntegrationTestSuite) TearDownTest() { os.RemoveAll(config.GetLocation(config.ConfigUser)) os.RemoveAll(config.GetLocation(config.ConfigSystem)) } + +func (suite *IntegrationTestSuite) driverIsInstalled(driverID string, level config.ConfigLevel) { + loc := config.GetLocation(level) + suite.FileExists(filepath.Join(loc, driverID+".toml")) +} diff --git a/cmd/dbc/integration_test_windows.go b/cmd/dbc/integration_test_windows.go index cdaa8de..0fe60c5 100644 --- a/cmd/dbc/integration_test_windows.go +++ b/cmd/dbc/integration_test_windows.go @@ -38,3 +38,17 @@ func (suite *IntegrationTestSuite) TearDownTest() { os.RemoveAll(config.GetLocation(config.ConfigUser)) os.RemoveAll(config.GetLocation(config.ConfigSystem)) } + +func (suite *IntegrationTestSuite) driverIsInstalled(driverID string, level config.ConfigLevel) { + // On Windows, drivers are registered in the Windows Registry + var rootKey registry.Key + if level == config.ConfigUser { + rootKey = registry.CURRENT_USER + } else { + rootKey = registry.LOCAL_MACHINE + } + + k, err := registry.OpenKey(rootKey, `SOFTWARE\ADBC\Drivers\`+driverID, registry.QUERY_VALUE) + suite.Require().NoError(err, "registry key should exist") + defer k.Close() +} From c3ed29f7a6aca3da73b99811285b85bd5374ff81 Mon Sep 17 00:00:00 2001 From: Bryce Mecum Date: Tue, 16 Dec 2025 17:25:49 -0800 Subject: [PATCH 08/11] Split user and system level tests --- .github/workflows/go.yml | 9 ++++++-- cmd/dbc/integation_user_test.go | 35 ++++++++++++++++++++++++++++++ cmd/dbc/integration_system_test.go | 35 ++++++++++++++++++++++++++++++ cmd/dbc/integration_test.go | 26 ---------------------- 4 files changed, 77 insertions(+), 28 deletions(-) create mode 100644 cmd/dbc/integation_user_test.go create mode 100644 cmd/dbc/integration_system_test.go diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 7266753..d4bfba9 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -59,11 +59,16 @@ jobs: # the file with `test_registry` also requires windows, so we can safely add this tag # without it running on non-windows OSes run: go test -v -tags test_registry ./... - - name: Run Integration Tests (Unix) + - name: Run User Integration Tests (Unix) if: runner.os != 'Windows' env: DBC_RUN_INTEGRATION_TESTS: 1 - run: sudo -E go test -v -tags test_integration -run TestIntegration ./cmd/dbc + run: go test -v -tags test_integration,test_user -run TestIntegration ./cmd/dbc + - name: Run System Integration Tests (Unix) + if: runner.os != 'Windows' + env: + DBC_RUN_INTEGRATION_TESTS: 1 + run: sudo go test -v -tags test_integration,test_system -run TestIntegration ./cmd/dbc - name: Run Integration Tests (Windows) if: runner.os == 'Windows' env: diff --git a/cmd/dbc/integation_user_test.go b/cmd/dbc/integation_user_test.go new file mode 100644 index 0000000..6c6d623 --- /dev/null +++ b/cmd/dbc/integation_user_test.go @@ -0,0 +1,35 @@ +// Copyright 2025 Columnar Technologies Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build test_integration,test_user + +package main + +import ( + "path/filepath" + + "github.com/columnar-tech/dbc/config" +) + +func (suite *IntegrationTestSuite) TestInstallUser() { + m := InstallCmd{Driver: "test-driver-1", Level: config.ConfigUser}. + GetModelCustom(baseModel{getDriverRegistry: getTestDriverRegistry, downloadPkg: downloadTestPkg}) + out := suite.run(m) + loc := config.GetLocation(config.ConfigUser) + + suite.Equal("\nInstalled test-driver-1 1.1.0 to "+loc+"\n", out) + suite.driverIsInstalled("test-driver-1", config.ConfigUser) + suite.FileExists(filepath.Join(loc, "test-driver-1.1", "test-driver-1-not-valid.so")) + suite.FileExists(filepath.Join(loc, "test-driver-1.1", "test-driver-1-not-valid.so.sig")) +} diff --git a/cmd/dbc/integration_system_test.go b/cmd/dbc/integration_system_test.go new file mode 100644 index 0000000..7077cc4 --- /dev/null +++ b/cmd/dbc/integration_system_test.go @@ -0,0 +1,35 @@ +// Copyright 2025 Columnar Technologies Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build test_integration,test_system + +package main + +import ( + "path/filepath" + + "github.com/columnar-tech/dbc/config" +) + +func (suite *IntegrationTestSuite) TestInstallSystem() { + m := InstallCmd{Driver: "test-driver-1", Level: config.ConfigSystem}. + GetModelCustom(baseModel{getDriverRegistry: getTestDriverRegistry, downloadPkg: downloadTestPkg}) + out := suite.run(m) + loc := config.GetLocation(config.ConfigSystem) + + suite.Equal("\nInstalled test-driver-1 1.1.0 to "+loc+"\n", out) + suite.driverIsInstalled("test-driver-1", config.ConfigSystem) + suite.FileExists(filepath.Join(loc, "test-driver-1.1", "test-driver-1-not-valid.so")) + suite.FileExists(filepath.Join(loc, "test-driver-1.1", "test-driver-1-not-valid.so.sig")) +} diff --git a/cmd/dbc/integration_test.go b/cmd/dbc/integration_test.go index 0d1be6c..abe67ef 100644 --- a/cmd/dbc/integration_test.go +++ b/cmd/dbc/integration_test.go @@ -20,12 +20,10 @@ import ( "bytes" "context" "os" - "path/filepath" "testing" "time" tea "github.com/charmbracelet/bubbletea" - "github.com/columnar-tech/dbc/config" "github.com/stretchr/testify/suite" ) @@ -66,27 +64,3 @@ func (s *IntegrationTestSuite) run(m tea.Model) string { func TestIntegration(t *testing.T) { suite.Run(t, new(IntegrationTestSuite)) } - -func (suite *IntegrationTestSuite) TestInstallUser() { - m := InstallCmd{Driver: "test-driver-1", Level: config.ConfigUser}. - GetModelCustom(baseModel{getDriverRegistry: getTestDriverRegistry, downloadPkg: downloadTestPkg}) - out := suite.run(m) - loc := config.GetLocation(config.ConfigUser) - - suite.Equal("\nInstalled test-driver-1 1.1.0 to "+loc+"\n", out) - suite.driverIsInstalled("test-driver-1", config.ConfigUser) - suite.FileExists(filepath.Join(loc, "test-driver-1.1", "test-driver-1-not-valid.so")) - suite.FileExists(filepath.Join(loc, "test-driver-1.1", "test-driver-1-not-valid.so.sig")) -} - -func (suite *IntegrationTestSuite) TestInstallSystem() { - m := InstallCmd{Driver: "test-driver-1", Level: config.ConfigSystem}. - GetModelCustom(baseModel{getDriverRegistry: getTestDriverRegistry, downloadPkg: downloadTestPkg}) - out := suite.run(m) - loc := config.GetLocation(config.ConfigSystem) - - suite.Equal("\nInstalled test-driver-1 1.1.0 to "+loc+"\n", out) - suite.driverIsInstalled("test-driver-1", config.ConfigSystem) - suite.FileExists(filepath.Join(loc, "test-driver-1.1", "test-driver-1-not-valid.so")) - suite.FileExists(filepath.Join(loc, "test-driver-1.1", "test-driver-1-not-valid.so.sig")) -} From cba9836857bfe394655443d9205589872e8ebea3 Mon Sep 17 00:00:00 2001 From: Bryce Mecum Date: Tue, 16 Dec 2025 17:26:48 -0800 Subject: [PATCH 09/11] whoops --- cmd/dbc/integation_user_test.go | 2 +- cmd/dbc/integration_system_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/dbc/integation_user_test.go b/cmd/dbc/integation_user_test.go index 6c6d623..5384801 100644 --- a/cmd/dbc/integation_user_test.go +++ b/cmd/dbc/integation_user_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -//go:build test_integration,test_user +//go:build test_integration && test_user package main diff --git a/cmd/dbc/integration_system_test.go b/cmd/dbc/integration_system_test.go index 7077cc4..1ad8af1 100644 --- a/cmd/dbc/integration_system_test.go +++ b/cmd/dbc/integration_system_test.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -//go:build test_integration,test_system +//go:build test_integration && test_system package main From 4b8ea3e5cf7ac08340feedf4c49757845f0d02ad Mon Sep 17 00:00:00 2001 From: Bryce Mecum Date: Tue, 16 Dec 2025 17:46:53 -0800 Subject: [PATCH 10/11] testing something --- cmd/dbc/integation_user_test.go | 4 ++-- cmd/dbc/integration_system_test.go | 4 ++-- cmd/dbc/integration_test_unix.go | 12 +++++++++--- cmd/dbc/integration_test_windows.go | 10 +++++++--- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/cmd/dbc/integation_user_test.go b/cmd/dbc/integation_user_test.go index 5384801..4637964 100644 --- a/cmd/dbc/integation_user_test.go +++ b/cmd/dbc/integation_user_test.go @@ -26,10 +26,10 @@ func (suite *IntegrationTestSuite) TestInstallUser() { m := InstallCmd{Driver: "test-driver-1", Level: config.ConfigUser}. GetModelCustom(baseModel{getDriverRegistry: getTestDriverRegistry, downloadPkg: downloadTestPkg}) out := suite.run(m) - loc := config.GetLocation(config.ConfigUser) + loc := config.GetLocation(config.ConfigUser) suite.Equal("\nInstalled test-driver-1 1.1.0 to "+loc+"\n", out) - suite.driverIsInstalled("test-driver-1", config.ConfigUser) + suite.driverIsInstalled(config.ConfigUser, "test-driver-1", "1.1.0") suite.FileExists(filepath.Join(loc, "test-driver-1.1", "test-driver-1-not-valid.so")) suite.FileExists(filepath.Join(loc, "test-driver-1.1", "test-driver-1-not-valid.so.sig")) } diff --git a/cmd/dbc/integration_system_test.go b/cmd/dbc/integration_system_test.go index 1ad8af1..10c1cf1 100644 --- a/cmd/dbc/integration_system_test.go +++ b/cmd/dbc/integration_system_test.go @@ -26,10 +26,10 @@ func (suite *IntegrationTestSuite) TestInstallSystem() { m := InstallCmd{Driver: "test-driver-1", Level: config.ConfigSystem}. GetModelCustom(baseModel{getDriverRegistry: getTestDriverRegistry, downloadPkg: downloadTestPkg}) out := suite.run(m) - loc := config.GetLocation(config.ConfigSystem) + loc := config.GetLocation(config.ConfigSystem) suite.Equal("\nInstalled test-driver-1 1.1.0 to "+loc+"\n", out) - suite.driverIsInstalled("test-driver-1", config.ConfigSystem) + suite.driverIsInstalled(config.ConfigSystem, "test-driver-1", "1.1.0") suite.FileExists(filepath.Join(loc, "test-driver-1.1", "test-driver-1-not-valid.so")) suite.FileExists(filepath.Join(loc, "test-driver-1.1", "test-driver-1-not-valid.so.sig")) } diff --git a/cmd/dbc/integration_test_unix.go b/cmd/dbc/integration_test_unix.go index 821d43f..7ad84a8 100644 --- a/cmd/dbc/integration_test_unix.go +++ b/cmd/dbc/integration_test_unix.go @@ -28,7 +28,13 @@ func (suite *IntegrationTestSuite) TearDownTest() { os.RemoveAll(config.GetLocation(config.ConfigSystem)) } -func (suite *IntegrationTestSuite) driverIsInstalled(driverID string, level config.ConfigLevel) { - loc := config.GetLocation(level) - suite.FileExists(filepath.Join(loc, driverID+".toml")) +func (suite *IntegrationTestSuite) driverIsInstalled(level config.ConfigLevel, path string) { + manifestPath := filepath.Join(cfg.Location, path+".toml") + suite.FileExists(manifestPath) + + driverInfo, err := config.GetDriver(cfg, path) + suite.Require().NoError(err, "should be able to load driver from manifest") + driverPath := driverInfo.Driver.Shared.Get(config.PlatformTuple()) + + suite.FileExists(driverPath) } diff --git a/cmd/dbc/integration_test_windows.go b/cmd/dbc/integration_test_windows.go index 0fe60c5..491bd3d 100644 --- a/cmd/dbc/integration_test_windows.go +++ b/cmd/dbc/integration_test_windows.go @@ -39,8 +39,7 @@ func (suite *IntegrationTestSuite) TearDownTest() { os.RemoveAll(config.GetLocation(config.ConfigSystem)) } -func (suite *IntegrationTestSuite) driverIsInstalled(driverID string, level config.ConfigLevel) { - // On Windows, drivers are registered in the Windows Registry +func (suite *IntegrationTestSuite) driverIsInstalled(level config.ConfigLevel, path string) { var rootKey registry.Key if level == config.ConfigUser { rootKey = registry.CURRENT_USER @@ -48,7 +47,12 @@ func (suite *IntegrationTestSuite) driverIsInstalled(driverID string, level conf rootKey = registry.LOCAL_MACHINE } - k, err := registry.OpenKey(rootKey, `SOFTWARE\ADBC\Drivers\`+driverID, registry.QUERY_VALUE) + k, err := registry.OpenKey(rootKey, `SOFTWARE\ADBC\Drivers\`+path, registry.QUERY_VALUE) suite.Require().NoError(err, "registry key should exist") defer k.Close() + + driverPath, _, err = k.GetStringValue("driver") + suite.Require().NoError(err) + + suite.FileExists(driverPath) } From 625273fd02f0277e3102fca67bdb6c543f56e846 Mon Sep 17 00:00:00 2001 From: Bryce Mecum Date: Tue, 16 Dec 2025 17:54:15 -0800 Subject: [PATCH 11/11] fixes --- cmd/dbc/integation_user_test.go | 2 +- cmd/dbc/integration_system_test.go | 2 +- cmd/dbc/integration_test_unix.go | 18 ++++++++++-------- cmd/dbc/integration_test_windows.go | 8 ++++---- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/cmd/dbc/integation_user_test.go b/cmd/dbc/integation_user_test.go index 4637964..b01f24c 100644 --- a/cmd/dbc/integation_user_test.go +++ b/cmd/dbc/integation_user_test.go @@ -29,7 +29,7 @@ func (suite *IntegrationTestSuite) TestInstallUser() { loc := config.GetLocation(config.ConfigUser) suite.Equal("\nInstalled test-driver-1 1.1.0 to "+loc+"\n", out) - suite.driverIsInstalled(config.ConfigUser, "test-driver-1", "1.1.0") + suite.driverIsInstalled(config.ConfigUser, "test-driver-1") suite.FileExists(filepath.Join(loc, "test-driver-1.1", "test-driver-1-not-valid.so")) suite.FileExists(filepath.Join(loc, "test-driver-1.1", "test-driver-1-not-valid.so.sig")) } diff --git a/cmd/dbc/integration_system_test.go b/cmd/dbc/integration_system_test.go index 10c1cf1..f7aa87e 100644 --- a/cmd/dbc/integration_system_test.go +++ b/cmd/dbc/integration_system_test.go @@ -29,7 +29,7 @@ func (suite *IntegrationTestSuite) TestInstallSystem() { loc := config.GetLocation(config.ConfigSystem) suite.Equal("\nInstalled test-driver-1 1.1.0 to "+loc+"\n", out) - suite.driverIsInstalled(config.ConfigSystem, "test-driver-1", "1.1.0") + suite.driverIsInstalled(config.ConfigSystem, "test-driver-1") suite.FileExists(filepath.Join(loc, "test-driver-1.1", "test-driver-1-not-valid.so")) suite.FileExists(filepath.Join(loc, "test-driver-1.1", "test-driver-1-not-valid.so.sig")) } diff --git a/cmd/dbc/integration_test_unix.go b/cmd/dbc/integration_test_unix.go index 7ad84a8..4efc09a 100644 --- a/cmd/dbc/integration_test_unix.go +++ b/cmd/dbc/integration_test_unix.go @@ -1,3 +1,5 @@ +//go:build test_integration && !windows + // Copyright 2025 Columnar Technologies Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -12,13 +14,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -//go:build test_integration && !windows - package main import ( "os" - "path/filepath" "github.com/columnar-tech/dbc/config" ) @@ -28,13 +27,16 @@ func (suite *IntegrationTestSuite) TearDownTest() { os.RemoveAll(config.GetLocation(config.ConfigSystem)) } -func (suite *IntegrationTestSuite) driverIsInstalled(level config.ConfigLevel, path string) { - manifestPath := filepath.Join(cfg.Location, path+".toml") - suite.FileExists(manifestPath) +func (suite *IntegrationTestSuite) driverIsInstalled(level config.ConfigLevel, driverID string) { + cfg := config.Config{ + Level: level, + Location: config.GetLocation(level), + } - driverInfo, err := config.GetDriver(cfg, path) + driverInfo, err := config.GetDriver(cfg, driverID) suite.Require().NoError(err, "should be able to load driver from manifest") - driverPath := driverInfo.Driver.Shared.Get(config.PlatformTuple()) + // Get and verify driver path exists + driverPath := driverInfo.Driver.Shared.Get(config.PlatformTuple()) suite.FileExists(driverPath) } diff --git a/cmd/dbc/integration_test_windows.go b/cmd/dbc/integration_test_windows.go index 491bd3d..aa23ab0 100644 --- a/cmd/dbc/integration_test_windows.go +++ b/cmd/dbc/integration_test_windows.go @@ -39,7 +39,7 @@ func (suite *IntegrationTestSuite) TearDownTest() { os.RemoveAll(config.GetLocation(config.ConfigSystem)) } -func (suite *IntegrationTestSuite) driverIsInstalled(level config.ConfigLevel, path string) { +func (suite *IntegrationTestSuite) driverIsInstalled(level config.ConfigLevel, driverID string) { var rootKey registry.Key if level == config.ConfigUser { rootKey = registry.CURRENT_USER @@ -47,12 +47,12 @@ func (suite *IntegrationTestSuite) driverIsInstalled(level config.ConfigLevel, p rootKey = registry.LOCAL_MACHINE } - k, err := registry.OpenKey(rootKey, `SOFTWARE\ADBC\Drivers\`+path, registry.QUERY_VALUE) + k, err := registry.OpenKey(rootKey, `SOFTWARE\ADBC\Drivers\`+driverID, registry.QUERY_VALUE) suite.Require().NoError(err, "registry key should exist") defer k.Close() - driverPath, _, err = k.GetStringValue("driver") + // Get and verify driver path exists + driverPath, _, err := k.GetStringValue("driver") suite.Require().NoError(err) - suite.FileExists(driverPath) }