-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed typo in error template for auth describe (#1341)
## Changes Fixed typo in error template for auth describe ## Tests Manually + added integration test
- Loading branch information
1 parent
77ff994
commit 60a4a34
Showing
2 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)") | ||
} |