fix: fix workspacesdk to return error on API mismatch (#13683)

This commit is contained in:
Spike Curtis
2024-06-27 15:02:43 +04:00
committed by GitHub
parent c4f1676055
commit 5b59f2880f
4 changed files with 66 additions and 3 deletions

View File

@ -46,8 +46,9 @@ func TestBlockNonBrowser(t *testing.T) {
},
})
r := setupWorkspaceAgent(t, client, user, 0)
ctx := testutil.Context(t, testutil.WaitShort)
//nolint:gocritic // Testing that even the owner gets blocked.
_, err := workspacesdk.New(client).DialAgent(context.Background(), r.sdkAgent.ID, nil)
_, err := workspacesdk.New(client).DialAgent(ctx, r.sdkAgent.ID, nil)
var apiErr *codersdk.Error
require.ErrorAs(t, err, &apiErr)
require.Equal(t, http.StatusConflict, apiErr.StatusCode())
@ -65,8 +66,9 @@ func TestBlockNonBrowser(t *testing.T) {
},
})
r := setupWorkspaceAgent(t, client, user, 0)
ctx := testutil.Context(t, testutil.WaitShort)
//nolint:gocritic // Testing RBAC is not the point of this test.
conn, err := workspacesdk.New(client).DialAgent(context.Background(), r.sdkAgent.ID, nil)
conn, err := workspacesdk.New(client).DialAgent(ctx, r.sdkAgent.ID, nil)
require.NoError(t, err)
_ = conn.Close()
})