Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
fjakobs committed Sep 4, 2024
1 parent 694413b commit 4cd9b17
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
4 changes: 2 additions & 2 deletions libs/runtime/detect.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
18 changes: 18 additions & 0 deletions libs/runtime/detect_test.go
Original file line number Diff line number Diff line change
@@ -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))
}
2 changes: 1 addition & 1 deletion libs/template/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4cd9b17

Please sign in to comment.