From bcce6b0ece7c7b5eece18d2c712246eb36cf6c97 Mon Sep 17 00:00:00 2001 From: Anton Nekipelov <226657+anton-107@users.noreply.github.com> Date: Tue, 4 Mar 2025 12:43:26 +0100 Subject: [PATCH] Enable TestAuthDescribeFailure integration test (#2420) ## Changes 1. remove t.Skip directive from TestAuthDescribeFailure integration test 2. remove checking the host in the test ## Why 1. This enables integration test that exercises `databricks auth describe` command, which was previously throwing errors in the CI/CD pipeline. For the nonexistent profile check to fail, we need to create a new profile file for the CLI to check (otherwise the configuration skips checking of the provided profile actually exists). 2. I removed the assertion for the host part because it is not relevant for the test, and setting that up just required more code in the test setup. ## Tests The integration test is passing --- integration/cmd/auth/describe_test.go | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/integration/cmd/auth/describe_test.go b/integration/cmd/auth/describe_test.go index 66b83b557..3d0a9b17d 100644 --- a/integration/cmd/auth/describe_test.go +++ b/integration/cmd/auth/describe_test.go @@ -2,10 +2,15 @@ package auth_test import ( "context" + "path/filepath" "regexp" "strings" "testing" + "github.com/databricks/cli/internal/testutil" + "github.com/databricks/cli/libs/databrickscfg" + "github.com/databricks/databricks-sdk-go/config" + "github.com/databricks/cli/internal/testcli" "github.com/databricks/databricks-sdk-go" "github.com/stretchr/testify/require" @@ -34,8 +39,19 @@ func TestAuthDescribeSuccess(t *testing.T) { } func TestAuthDescribeFailure(t *testing.T) { - t.Skipf("Skipping because of https://github.com/databricks/cli/issues/2010") + testutil.CleanupEnvironment(t) + // set up a custom config file: + home := t.TempDir() + cfg := &config.Config{ + ConfigFile: filepath.Join(home, "customcfg"), + Profile: "profile1", + } + err := databrickscfg.SaveToProfile(context.Background(), cfg) + require.NoError(t, err) + t.Setenv("DATABRICKS_CONFIG_FILE", filepath.Join(home, "customcfg")) + + // run the command: ctx := context.Background() stdout, _ := testcli.RequireSuccessfulRun(t, ctx, "auth", "describe", "--profile", "nonexistent") outStr := stdout.String() @@ -44,10 +60,5 @@ func TestAuthDescribeFailure(t *testing.T) { require.Contains(t, outStr, "Unable to authenticate: resolve") require.Contains(t, outStr, "has no nonexistent profile configured") require.Contains(t, outStr, "Current configuration:") - - w, err := databricks.NewWorkspaceClient(&databricks.Config{}) - require.NoError(t, err) - - require.Contains(t, outStr, "✓ host: "+w.Config.Host) require.Contains(t, outStr, "✓ profile: nonexistent (from --profile flag)") }