mirror of https://github.com/databricks/cli.git
29 lines
525 B
Go
29 lines
525 B
Go
|
package env
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"testing"
|
||
|
|
||
|
"github.com/databricks/cli/internal/testutil"
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
)
|
||
|
|
||
|
func TestTempDir(t *testing.T) {
|
||
|
ctx := context.Background()
|
||
|
|
||
|
testutil.CleanupEnvironment(t)
|
||
|
|
||
|
t.Run("set", func(t *testing.T) {
|
||
|
t.Setenv("DATABRICKS_BUNDLE_TMP", "foo")
|
||
|
tempDir, ok := TempDir(ctx)
|
||
|
assert.True(t, ok)
|
||
|
assert.Equal(t, "foo", tempDir)
|
||
|
})
|
||
|
|
||
|
t.Run("not set", func(t *testing.T) {
|
||
|
tempDir, ok := TempDir(ctx)
|
||
|
assert.False(t, ok)
|
||
|
assert.Equal(t, "", tempDir)
|
||
|
})
|
||
|
}
|