Skip to content

coderd: autostart: codersdk, http api, database plumbing #879

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

Merged
merged 16 commits into from
Apr 7, 2022
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix: coderd: add test for nonexistent workspace
  • Loading branch information
johnstcn committed Apr 6, 2022
commit ff80571eed293b2c414e351459b0808d0aa7ccbd
16 changes: 16 additions & 0 deletions coderd/workspaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package coderd_test

import (
"context"
"fmt"
"net/http"
"testing"
"time"
Expand Down Expand Up @@ -292,6 +293,21 @@ func TestWorkspaceUpdateAutostart(t *testing.T) {
require.Equal(t, testCase.expectedInterval, interval, "unexpected interval")
})
}

t.Run("NotFound", func(t *testing.T) {
var (
ctx = context.Background()
client = coderdtest.New(t, nil)
_ = coderdtest.CreateFirstUser(t, client)
wsid = uuid.New()
req = codersdk.UpdateWorkspaceAutostartRequest{
Schedule: "9 30 1-5",
}
)

err := client.UpdateWorkspaceAutostart(ctx, wsid, req)
require.EqualError(t, err, fmt.Sprintf("status code 404: workspace %q does not exist", wsid), "unexpected error")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: We could assert to codersdk.Error here to check the status code!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI I ended up needing to squelch a linter error when trying to use errors.As on codersdk.Error.
This is the sort of thing I ended up with: https://go.dev/play/p/NHTmnYWan6g

})
}

func mustLocation(t *testing.T, location string) *time.Location {
Expand Down