mirror of https://github.com/databricks/cli.git
Example: use TESTS_DATABRICKS_HOST in integration tests
This serves 2 purposes: - flag to enable integration tests; without this env var they are not run - way to pass DATABRICKS_HOST without accidentally picking user's real config
This commit is contained in:
parent
61b0c59137
commit
c26b724946
|
@ -0,0 +1,23 @@
|
|||
package internal
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
// 1. Redefine env vars to avoid accidentally picking up user's credentials
|
||||
// 2. TESTS_DATABRICKS_TOKEN is also a gate enabling integration tests
|
||||
host := os.Getenv("TESTS_DATABRICKS_HOST")
|
||||
if host == "" {
|
||||
fmt.Println("TESTS_DATABRICKS_HOST is not set, skipping integration tests")
|
||||
return
|
||||
}
|
||||
token := os.Getenv("TESTS_DATABRICKS_TOKEN")
|
||||
|
||||
os.Setenv("DATABRICKS_HOST", host)
|
||||
os.Setenv("DATABRICKS_TOKEN", token)
|
||||
|
||||
m.Run()
|
||||
}
|
Loading…
Reference in New Issue