Skip to content

Commit 361d274

Browse files
committed
fix(users): return false on 409 in /activate and /deactivate
1 parent 064882b commit 361d274

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/users/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,12 @@ const users = (connection: ConnectionREST): Users => {
147147
const db = (connection: ConnectionREST): DBUsers => {
148148
const ns = namespacedUsers(connection);
149149

150-
/** expectCode returns true if the error contained an expected status code. */
150+
/** expectCode returns false if the contained WeaviateUnexpectedStatusCodeError
151+
* has an known error code and rethrows the error otherwise. */
151152
const expectCode = (code: number): ((_: any) => boolean) => {
152153
return (error) => {
153-
if (error instanceof WeaviateUnexpectedStatusCodeError) {
154-
return error.code === code;
154+
if (error instanceof WeaviateUnexpectedStatusCodeError && error.code === code) {
155+
return false;
155156
}
156157
throw error;
157158
};

src/users/integration.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ requireAtLeast(
7979
await expectDave().toHaveProperty('active', true);
8080

8181
// Second activation is a no-op
82-
await expect(client.users.db.activate('dynamic-dave')).resolves.toEqual(true);
82+
await expect(client.users.db.activate('dynamic-dave')).resolves.toEqual(false);
8383

8484
await client.users.db.deactivate('dynamic-dave');
8585
await expectDave().toHaveProperty('active', false);
8686

8787
// Second deactivation is a no-op
88-
await expect(client.users.db.deactivate('dynamic-dave', { revokeKey: true })).resolves.toEqual(true);
88+
await expect(client.users.db.deactivate('dynamic-dave', { revokeKey: true })).resolves.toEqual(false);
8989

9090
await client.users.db.delete('dynamic-dave');
9191
await expectDave(false).toHaveProperty('code', 404);

0 commit comments

Comments
 (0)