mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
fix: coderd: putExtendWorkspace: move error from validation to message (#3289)
* refactor: coderd: extract error messages to variables * fix: putExtendWorkspace: return validation error in message field
This commit is contained in:
@ -1063,14 +1063,15 @@ func TestWorkspaceExtend(t *testing.T) {
|
||||
err = client.PutExtendWorkspace(ctx, workspace.ID, codersdk.PutExtendWorkspaceRequest{
|
||||
Deadline: deadlineTooSoon,
|
||||
})
|
||||
require.ErrorContains(t, err, "new deadline must be at least 30 minutes in the future", "setting a deadline less than 30 minutes in the future should fail")
|
||||
require.ErrorContains(t, err, "unexpected status code 400: Cannot extend workspace: new deadline must be at least 30 minutes in the future", "setting a deadline less than 30 minutes in the future should fail")
|
||||
|
||||
// And with a deadline greater than the template max_ttl should also fail
|
||||
deadlineExceedsMaxTTL := time.Now().Add(time.Duration(template.MaxTTLMillis) * time.Millisecond).Add(time.Minute)
|
||||
err = client.PutExtendWorkspace(ctx, workspace.ID, codersdk.PutExtendWorkspaceRequest{
|
||||
Deadline: deadlineExceedsMaxTTL,
|
||||
})
|
||||
require.ErrorContains(t, err, "new deadline is greater than template allows", "setting a deadline greater than that allowed by the template should fail")
|
||||
|
||||
require.ErrorContains(t, err, "unexpected status code 400: Cannot extend workspace: new deadline is greater than template allows", "setting a deadline greater than that allowed by the template should fail")
|
||||
|
||||
// Updating with a deadline 30 minutes in the future should succeed
|
||||
deadlineJustSoonEnough := time.Now().Add(30 * time.Minute)
|
||||
|
Reference in New Issue
Block a user