Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed typo in error template for auth describe #1341

Merged
merged 2 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/auth/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var authTemplate = `{{"Host:" | bold}} {{.Status.Details.Host}}
-----
` + configurationTemplate

var errorTemplate = `Unable to authenticate: {{.Error}}
var errorTemplate = `Unable to authenticate: {{.Status.Error}}
-----
` + configurationTemplate

Expand Down
49 changes: 49 additions & 0 deletions internal/auth_describe_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package internal

import (
"context"
"fmt"
"testing"

"github.com/databricks/databricks-sdk-go"
"github.com/stretchr/testify/require"
)

func TestAuthDescribeSuccess(t *testing.T) {
t.Log(GetEnvOrSkipTest(t, "CLOUD_ENV"))

stdout, _ := RequireSuccessfulRun(t, "auth", "describe")
outStr := stdout.String()

w, err := databricks.NewWorkspaceClient(&databricks.Config{})
require.NoError(t, err)

require.NotEmpty(t, outStr)
require.Contains(t, outStr, fmt.Sprintf("Host: %s", w.Config.Host))

me, err := w.CurrentUser.Me(context.Background())
require.NoError(t, err)
require.Contains(t, outStr, fmt.Sprintf("User: %s", me.UserName))
require.Contains(t, outStr, fmt.Sprintf("Authenticated with: %s", w.Config.AuthType))
require.Contains(t, outStr, "Current configuration:")
require.Contains(t, outStr, fmt.Sprintf("✓ host: %s", w.Config.Host))
require.Contains(t, outStr, "✓ profile: default")
}

func TestAuthDescribeFailure(t *testing.T) {
t.Log(GetEnvOrSkipTest(t, "CLOUD_ENV"))

stdout, _ := RequireSuccessfulRun(t, "auth", "describe", "--profile", "nonexistent")
outStr := stdout.String()

require.NotEmpty(t, outStr)
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, fmt.Sprintf("✓ host: %s", w.Config.Host))
require.Contains(t, outStr, "✓ profile: nonexistent (from --profile flag)")
}
Loading