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
This commit is contained in:
Anton Nekipelov 2025-03-04 12:43:26 +01:00 committed by GitHub
parent 010f88f84e
commit bcce6b0ece
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 17 additions and 6 deletions

View File

@ -2,10 +2,15 @@ package auth_test
import ( import (
"context" "context"
"path/filepath"
"regexp" "regexp"
"strings" "strings"
"testing" "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/cli/internal/testcli"
"github.com/databricks/databricks-sdk-go" "github.com/databricks/databricks-sdk-go"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
@ -34,8 +39,19 @@ func TestAuthDescribeSuccess(t *testing.T) {
} }
func TestAuthDescribeFailure(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() ctx := context.Background()
stdout, _ := testcli.RequireSuccessfulRun(t, ctx, "auth", "describe", "--profile", "nonexistent") stdout, _ := testcli.RequireSuccessfulRun(t, ctx, "auth", "describe", "--profile", "nonexistent")
outStr := stdout.String() outStr := stdout.String()
@ -44,10 +60,5 @@ func TestAuthDescribeFailure(t *testing.T) {
require.Contains(t, outStr, "Unable to authenticate: resolve") require.Contains(t, outStr, "Unable to authenticate: resolve")
require.Contains(t, outStr, "has no nonexistent profile configured") require.Contains(t, outStr, "has no nonexistent profile configured")
require.Contains(t, outStr, "Current configuration:") 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)") require.Contains(t, outStr, "✓ profile: nonexistent (from --profile flag)")
} }