This commit is contained in:
Shreyas Goenka 2025-02-05 20:48:08 +01:00
parent 73fac825ce
commit 5e2e03a90c
No known key found for this signature in database
GPG Key ID: 92A07DF49CCB0622
1 changed files with 4 additions and 5 deletions

View File

@ -10,7 +10,6 @@ import (
"github.com/databricks/cli/internal/testutil" "github.com/databricks/cli/internal/testutil"
"github.com/databricks/cli/libs/telemetry/protos" "github.com/databricks/cli/libs/telemetry/protos"
"github.com/databricks/cli/libs/testserver" "github.com/databricks/cli/libs/testserver"
"github.com/databricks/databricks-sdk-go/apierr"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
@ -21,19 +20,19 @@ func TestTelemetryUpload(t *testing.T) {
t.Cleanup(server.Close) t.Cleanup(server.Close)
count := 0 count := 0
server.Handle("POST /telemetry-ext", func(req *http.Request) (resp any, err error) { server.Handle("POST /telemetry-ext", func(req *http.Request) (resp any, statusCode int) {
count++ count++
if count == 1 { if count == 1 {
return ResponseBody{ return ResponseBody{
NumProtoSuccess: 1, NumProtoSuccess: 1,
}, nil }, http.StatusOK
} }
if count == 2 { if count == 2 {
return ResponseBody{ return ResponseBody{
NumProtoSuccess: 2, NumProtoSuccess: 2,
}, nil }, http.StatusOK
} }
return nil, apierr.NotFound("not found") return nil, http.StatusInternalServerError
}) })
t.Setenv("DATABRICKS_HOST", server.URL) t.Setenv("DATABRICKS_HOST", server.URL)