mirror of https://github.com/databricks/cli.git
add test
This commit is contained in:
parent
694413b115
commit
4cd9b17625
|
@ -9,6 +9,6 @@ import (
|
|||
const envDatabricksRuntimeVersion = "DATABRICKS_RUNTIME_VERSION"
|
||||
|
||||
func RunsOnDatabricks(ctx context.Context) bool {
|
||||
_, ok := env.Lookup(ctx, envDatabricksRuntimeVersion)
|
||||
return ok
|
||||
value, ok := env.Lookup(ctx, envDatabricksRuntimeVersion)
|
||||
return value != "" && ok
|
||||
}
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
package runtime
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestRunsOnDatabricks(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
t.Setenv("DATABRICKS_RUNTIME_VERSION", "")
|
||||
assert.False(t, RunsOnDatabricks(ctx))
|
||||
|
||||
t.Setenv("DATABRICKS_RUNTIME_VERSION", "14.3")
|
||||
assert.True(t, RunsOnDatabricks(ctx))
|
||||
}
|
|
@ -115,7 +115,7 @@ func shouldUseImportNotebook(ctx context.Context, path string, content []byte) b
|
|||
if err != nil {
|
||||
log.Debugf(ctx, "Error detecting notebook: %v", err)
|
||||
}
|
||||
return isNotebook && err != nil
|
||||
return isNotebook && err == nil
|
||||
}
|
||||
|
||||
return false
|
||||
|
|
Loading…
Reference in New Issue