fix tests

This commit is contained in:
Shreyas Goenka 2024-12-27 13:42:06 +05:30
parent 44d43fccb7
commit 2eb3344edb
No known key found for this signature in database
GPG Key ID: 92A07DF49CCB0622
3 changed files with 5 additions and 3 deletions

View File

@ -19,6 +19,7 @@ import (
"github.com/databricks/cli/libs/filer"
"github.com/databricks/cli/libs/flags"
"github.com/databricks/cli/libs/folders"
"github.com/databricks/cli/libs/telemetry"
"github.com/databricks/cli/libs/template"
"github.com/databricks/databricks-sdk-go"
"github.com/stretchr/testify/require"
@ -28,6 +29,7 @@ const defaultSparkVersion = "13.3.x-snapshot-scala2.12"
func initTestTemplate(t testutil.TestingT, ctx context.Context, templateName string, config map[string]any) string {
bundleRoot := t.TempDir()
ctx = telemetry.ContextWithLogger(ctx)
return initTestTemplateWithBundleRoot(t, ctx, templateName, config, bundleRoot)
}

View File

@ -240,7 +240,7 @@ func TestBundleInitTelemetryForCustomTemplates(t *testing.T) {
testcli.RequireSuccessfulRun(t, ctx, "bundle", "init", tmpDir1, "--output-dir", tmpDir2, "--config-file", filepath.Join(tmpDir3, "config.json"))
// Assert the telemetry payload is correctly logged. For custom templates we should
//
// never set template_enum_args.
logs, err := telemetry.GetLogs(ctx)
require.NoError(t, err)
require.Equal(t, 1, len(logs))

View File

@ -41,8 +41,8 @@ type logger struct {
protoLogs []string
}
// Only to be used in tests to introspect the telemetry logs that are queued
// to be flushed.
// This function is meant to be only to be used in tests to introspect the telemetry logs
// that have been logged so far.
func GetLogs(ctx context.Context) ([]FrontendLog, error) {
l := fromContext(ctx)
res := []FrontendLog{}