@@ -120,6 +120,36 @@ func (suite *SubcommandTestSuite) TestInstallVenv() {
120120 "\n Installed test-driver-1 1.1.0 to " + filepath .Join (suite .tempdir , "etc" , "adbc" , "drivers" )+ "\n " , suite .runCmd (m ))
121121}
122122
123+ func (suite * SubcommandTestSuite ) TestInstallEnvironmentPrecedence () {
124+ // Like the driver managers, dbc follows a precedence chain when
125+ // ADBC_DRIVER_MANAGER, VIRTUAL_ENV, and CONDA_PREFIX are set with each
126+ // variable overriding the next.
127+ driver_path := filepath .Join (suite .tempdir , "driver_path" )
128+ venv_path := filepath .Join (suite .tempdir , "venv_path" )
129+ conda_path := filepath .Join (suite .tempdir , "conda_path" )
130+ os .Setenv ("ADBC_DRIVER_PATH" , driver_path )
131+ os .Setenv ("VIRTUAL_ENV" , venv_path )
132+ os .Setenv ("CONDA_PREFIX" , conda_path )
133+
134+ m := InstallCmd {Driver : "test-driver-1" , Level : config .ConfigEnv }.
135+ GetModelCustom (baseModel {getDriverList : getTestDriverList , downloadPkg : downloadTestPkg })
136+ suite .runCmd (m )
137+
138+ suite .FileExists (filepath .Join (driver_path , "test-driver-1.toml" ))
139+ suite .NoFileExists (filepath .Join (venv_path , "test-driver-1.toml" ))
140+ suite .NoFileExists (filepath .Join (conda_path , "test-driver-1.toml" ))
141+
142+ os .Unsetenv ("ADBC_DRIVER_PATH" )
143+ suite .FileExists (filepath .Join (venv_path , "test-driver-1.toml" ))
144+ suite .NoFileExists (filepath .Join (conda_path , "test-driver-1.toml" ))
145+
146+ os .Unsetenv ("VIRTUAL_ENV" )
147+ suite .FileExists (filepath .Join (conda_path , "test-driver-1.toml" ))
148+
149+ os .Unsetenv ("CONDA_PREFIX" )
150+ suite .FileExists (filepath .Join (suite .tempdir , "test-driver-1.toml" ))
151+ }
152+
123153func (suite * SubcommandTestSuite ) TestInstallCondaPrefix () {
124154 os .Unsetenv ("ADBC_DRIVER_PATH" )
125155 os .Setenv ("CONDA_PREFIX" , suite .tempdir )
0 commit comments