Skip to content

Commit 8985605

Browse files
committed
Delete job after test
1 parent 90dc4e2 commit 8985605

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

internal/acc/debug.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ import (
55
"os"
66
"path"
77
"path/filepath"
8+
"strings"
89
"testing"
910
)
1011

1112
// Detects if test is run from "debug test" feature in VS Code.
1213
func isInDebug() bool {
1314
ex, _ := os.Executable()
14-
return path.Base(ex) == "__debug_bin"
15+
return strings.HasPrefix(path.Base(ex), "__debug_bin")
1516
}
1617

1718
// Loads debug environment from ~/.databricks/debug-env.json.

internal/jobs_test.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
11
package internal
22

33
import (
4+
"encoding/json"
5+
"fmt"
46
"testing"
7+
8+
"github.com/databricks/cli/internal/acc"
9+
"github.com/stretchr/testify/assert"
510
)
611

712
func TestAccCreateJob(t *testing.T) {
8-
t.Log(GetEnvOrSkipTest(t, "CLOUD_ENV"))
9-
RequireSuccessfulRun(t, "jobs", "create", "--json", "@testjsons/create_job_without_cluster.json", "--log-level=debug")
13+
acc.WorkspaceTest(t)
14+
env := GetEnvOrSkipTest(t, "CLOUD_ENV")
15+
if env != "azure" {
16+
t.Skipf("Not running test on cloud %s", env)
17+
}
18+
stdout, stderr := RequireSuccessfulRun(t, "jobs", "create", "--json", "@testjsons/create_job_without_cluster.json", "--log-level=debug")
19+
assert.Equal(t, "", stderr.String())
20+
var output map[string]int
21+
err := json.Unmarshal(stdout.Bytes(), &output)
22+
assert.NoError(t, err)
23+
RequireSuccessfulRun(t, "jobs", "delete", fmt.Sprint(output["job_id"]), "--log-level=debug")
1024
}

0 commit comments

Comments
 (0)