From 0ac536f1888675e496ae34f7ab846b40058a254d Mon Sep 17 00:00:00 2001 From: Shreyas Goenka Date: Fri, 3 Jan 2025 00:46:07 +0530 Subject: [PATCH] lint --- cmd/bundle/init_test.go | 2 +- integration/bundle/init_test.go | 18 +++++++++--------- integration/libs/telemetry/telemetry_test.go | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cmd/bundle/init_test.go b/cmd/bundle/init_test.go index dabe7687e..b8d057113 100644 --- a/cmd/bundle/init_test.go +++ b/cmd/bundle/init_test.go @@ -54,5 +54,5 @@ func TestGetNativeTemplateByName(t *testing.T) { assert.Equal(t, "The default Python template for Notebooks / Delta Live Tables / Workflows", getNativeTemplateByName("default-python").description) assert.Equal(t, "", getNativeTemplateByName("default-python").gitUrl) - assert.Nil(t, nil, getNativeTemplateByName("invalid")) + assert.Nil(t, getNativeTemplateByName("invalid")) } diff --git a/integration/bundle/init_test.go b/integration/bundle/init_test.go index 17672b3af..1bd7e0034 100644 --- a/integration/bundle/init_test.go +++ b/integration/bundle/init_test.go @@ -73,9 +73,9 @@ func TestBundleInitOnMlopsStacks(t *testing.T) { // Assert the telemetry payload is correctly logged. logs := telemetry.GetLogs(ctx) require.NoError(t, err) - require.Equal(t, 1, len(logs)) + require.Len(t, len(logs), 1) event := logs[0].Entry.DatabricksCliLog.BundleInitEvent - assert.Equal(t, event.TemplateName, "mlops-stacks") + assert.Equal(t, "mlops-stacks", event.TemplateName) get := func(key string) string { for _, v := range event.TemplateEnumArgs { @@ -87,11 +87,11 @@ func TestBundleInitOnMlopsStacks(t *testing.T) { } // Enum values should be present in the telemetry payload. - assert.Equal(t, get("input_include_models_in_unity_catalog"), "no") - assert.Equal(t, get("input_cloud"), strings.ToLower(env)) + assert.Equal(t, "no", get("input_include_models_in_unity_catalog")) + assert.Equal(t, strings.ToLower(env), get("input_cloud")) // Freeform strings should not be present in the telemetry payload. - assert.Equal(t, get("input_project_name"), "") - assert.Equal(t, get("input_root_dir"), "") + assert.Equal(t, "", get("input_project_name")) + assert.Equal(t, "", get("input_root_dir")) // Assert that the README.md file was created contents := testutil.ReadFile(t, filepath.Join(tmpDir2, "repo_name", projectName, "README.md")) @@ -200,7 +200,7 @@ func TestBundleInitTelemetryForDefaultTemplates(t *testing.T) { // Assert the telemetry payload is correctly logged. logs := telemetry.GetLogs(ctx) require.NoError(t, err) - require.Equal(t, 1, len(logs)) + require.Len(t, len(logs), 1) event := logs[0].Entry.DatabricksCliLog.BundleInitEvent assert.Equal(t, event.TemplateName, tc.name) @@ -269,9 +269,9 @@ func TestBundleInitTelemetryForCustomTemplates(t *testing.T) { // never set template_enum_args. logs := telemetry.GetLogs(ctx) require.NoError(t, err) - require.Equal(t, 1, len(logs)) + require.Len(t, len(logs), 1) event := logs[0].Entry.DatabricksCliLog.BundleInitEvent - assert.Equal(t, event.TemplateName, "custom") + assert.Equal(t, "custom", event.TemplateName) assert.Empty(t, event.TemplateEnumArgs) // Ensure that the UUID returned by the `bundle_uuid` helper is the same UUID diff --git a/integration/libs/telemetry/telemetry_test.go b/integration/libs/telemetry/telemetry_test.go index 5fdceb2cd..8d5948b4b 100644 --- a/integration/libs/telemetry/telemetry_test.go +++ b/integration/libs/telemetry/telemetry_test.go @@ -57,7 +57,7 @@ func TestTelemetryLogger(t *testing.T) { }, } - assert.Equal(t, reflect.TypeOf(telemetry.DatabricksCliLog{}).NumField(), len(events), + assert.Len(t, reflect.TypeOf(telemetry.DatabricksCliLog{}).NumField(), len(events), "Number of events should match the number of fields in DatabricksCliLog. Please add a new event to this test.") ctx, w := acc.WorkspaceTest(t)