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

backend/remote: remove milseading contents from error message #22148

Merged
merged 1 commit into from
Jul 22, 2019
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
6 changes: 1 addition & 5 deletions backend/remote/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -657,11 +657,7 @@ func (b *Remote) Operation(ctx context.Context, op *backend.Operation) (*backend
)
default:
return nil, fmt.Errorf(
"%s\n\n"+
"The configured \"remote\" backend encountered an unexpected error. Sometimes\n"+
"this is caused by network connection problems, in which case you could retr\n"+
"the command. If the issue persists please open a support ticket to get help\n"+
"resolving the problem.",
"The configured \"remote\" backend encountered an unexpected error:\n\n%s",
err,
)
}
Expand Down
5 changes: 5 additions & 0 deletions backend/remote/backend_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,11 @@ func (m *mockWorkspaces) Create(ctx context.Context, organization string, option
}

func (m *mockWorkspaces) Read(ctx context.Context, organization, workspace string) (*tfe.Workspace, error) {
// custom error for TestRemote_plan500 in backend_plan_test.go
if workspace == "network-error" {
return nil, errors.New("I'm a little teacup")
}

w, ok := m.workspaceNames[workspace]
if !ok {
return nil, tfe.ErrResourceNotFound
Expand Down
20 changes: 20 additions & 0 deletions backend/remote/backend_plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -855,3 +855,23 @@ func TestRemote_planWithRemoteError(t *testing.T) {
t.Fatalf("expected plan error in output: %s", output)
}
}

func TestRemote_planOtherError(t *testing.T) {
b, bCleanup := testBackendDefault(t)
defer bCleanup()

op, configCleanup := testOperationPlan(t, "./testdata/plan")
defer configCleanup()

op.Workspace = "network-error" // custom error response in backend_mock.go

_, err := b.Operation(context.Background(), op)
if err == nil {
t.Errorf("expected error, got success")
}

if !strings.Contains(err.Error(),
"The configured \"remote\" backend encountered an unexpected error:\n\nI'm a little teacup") {
t.Fatalf("expected error message, got: %s", err.Error())
}
}