@datalayer/core 0.0.12 → 0.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/lib/api/DatalayerApi.d.ts +38 -26
- package/lib/api/DatalayerApi.js +52 -13
- package/lib/api/iam/authentication.d.ts +9 -8
- package/lib/api/iam/authentication.js +14 -15
- package/lib/api/iam/healthz.d.ts +3 -2
- package/lib/api/iam/healthz.js +5 -3
- package/lib/api/iam/index.d.ts +9 -4
- package/lib/api/iam/index.js +9 -4
- package/lib/api/iam/oauth2.d.ts +115 -0
- package/lib/api/iam/oauth2.js +309 -0
- package/lib/api/iam/profile.d.ts +8 -1
- package/lib/api/iam/profile.js +17 -2
- package/lib/api/iam/usage.d.ts +18 -0
- package/lib/api/iam/usage.js +39 -0
- package/lib/api/index.d.ts +6 -6
- package/lib/api/index.js +6 -7
- package/lib/api/runtimes/environments.d.ts +2 -2
- package/lib/api/runtimes/environments.js +3 -2
- package/lib/api/runtimes/healthz.d.ts +3 -13
- package/lib/api/runtimes/healthz.js +4 -3
- package/lib/api/runtimes/index.d.ts +3 -2
- package/lib/api/runtimes/index.js +3 -2
- package/lib/api/runtimes/runtimes.d.ts +4 -4
- package/lib/api/runtimes/runtimes.js +17 -6
- package/lib/api/runtimes/snapshots.d.ts +4 -4
- package/lib/api/runtimes/snapshots.js +3 -2
- package/lib/api/spacer/documents.d.ts +12 -0
- package/lib/api/spacer/documents.js +43 -0
- package/lib/api/spacer/healthz.d.ts +3 -13
- package/lib/api/spacer/healthz.js +4 -3
- package/lib/api/spacer/index.d.ts +4 -2
- package/lib/api/spacer/index.js +4 -2
- package/lib/api/spacer/items.d.ts +9 -1
- package/lib/api/spacer/items.js +17 -2
- package/lib/api/spacer/lexicals.d.ts +1 -1
- package/lib/api/spacer/lexicals.js +3 -2
- package/lib/api/spacer/notebooks.d.ts +1 -1
- package/lib/api/spacer/notebooks.js +3 -2
- package/lib/api/spacer/spaces.d.ts +1 -1
- package/lib/api/spacer/spaces.js +3 -2
- package/lib/api/spacer/users.d.ts +1 -1
- package/lib/api/spacer/users.js +3 -2
- package/lib/api/utils/validation.d.ts +24 -1
- package/lib/api/utils/validation.js +62 -1
- package/lib/client/base.d.ts +75 -0
- package/lib/client/base.js +199 -0
- package/lib/client/constants.d.ts +22 -0
- package/lib/client/constants.js +22 -0
- package/lib/client/index.d.ts +108 -0
- package/lib/client/index.js +79 -0
- package/lib/client/mixins/IAMMixin.d.ts +54 -0
- package/lib/client/mixins/IAMMixin.js +181 -0
- package/lib/client/mixins/RuntimesMixin.d.ts +93 -0
- package/lib/client/mixins/RuntimesMixin.js +229 -0
- package/lib/client/mixins/SpacerMixin.d.ts +111 -0
- package/lib/client/mixins/SpacerMixin.js +340 -0
- package/lib/client/utils/mixins.d.ts +12 -0
- package/lib/{sdk/client → client}/utils/mixins.js +0 -28
- package/lib/client/utils/spacerUtils.d.ts +18 -0
- package/lib/client/utils/spacerUtils.js +32 -0
- package/lib/collaboration/DatalayerCollaboration.d.ts +6 -1
- package/lib/collaboration/DatalayerCollaboration.js +2 -2
- package/lib/collaboration/DatalayerCollaborationProvider.d.ts +5 -0
- package/lib/collaboration/DatalayerCollaborationProvider.js +10 -9
- package/lib/components/progress/CreditsIndicator.d.ts +1 -1
- package/lib/components/runtimes/RuntimeCellVariablesDialog.js +1 -1
- package/lib/components/runtimes/RuntimeLauncherDialog.d.ts +1 -1
- package/lib/components/runtimes/RuntimeLauncherDialog.js +2 -2
- package/lib/components/runtimes/RuntimePickerBase.d.ts +1 -1
- package/lib/components/runtimes/RuntimePickerBase.js +1 -1
- package/lib/components/runtimes/RuntimePickerCell.js +3 -3
- package/lib/components/runtimes/RuntimePickerNotebook.d.ts +1 -1
- package/lib/components/runtimes/RuntimePickerNotebook.js +2 -2
- package/lib/components/runtimes/RuntimeTransfer.d.ts +2 -2
- package/lib/components/runtimes/RuntimeUtils.d.ts +1 -1
- package/lib/components/snapshots/RuntimeSnapshotMenu.d.ts +1 -1
- package/lib/components/snapshots/RuntimeSnapshotMenu.js +27 -20
- package/lib/config/Configuration.d.ts +8 -0
- package/lib/hooks/useDatalayer.js +1 -1
- package/lib/hooks/useRuntimes.js +1 -1
- package/lib/hooks/useToast.js +1 -1
- package/lib/index.d.ts +2 -3
- package/lib/index.js +4 -3
- package/lib/models/Common.d.ts +64 -0
- package/lib/models/CreditsDTO.d.ts +124 -0
- package/lib/models/CreditsDTO.js +135 -0
- package/lib/models/Environment.d.ts +1 -1
- package/lib/models/EnvironmentDTO.d.ts +125 -0
- package/lib/models/EnvironmentDTO.js +88 -0
- package/lib/models/HealthCheck.d.ts +72 -0
- package/lib/models/HealthCheck.js +107 -0
- package/lib/{api/types/iam.d.ts → models/IAM.d.ts} +15 -78
- package/lib/models/ItemDTO.d.ts +74 -0
- package/lib/models/ItemDTO.js +186 -0
- package/lib/models/LexicalDTO.d.ts +155 -0
- package/lib/models/LexicalDTO.js +157 -0
- package/lib/models/NotebookDTO.d.ts +96 -0
- package/lib/models/NotebookDTO.js +153 -0
- package/lib/models/Profile.d.ts +65 -0
- package/lib/models/RuntimeDTO.d.ts +191 -0
- package/lib/models/RuntimeDTO.js +204 -0
- package/lib/models/RuntimeSnapshotDTO.d.ts +173 -0
- package/lib/models/RuntimeSnapshotDTO.js +139 -0
- package/lib/models/SpaceDTO.d.ts +280 -0
- package/lib/models/SpaceDTO.js +239 -0
- package/lib/models/UserDTO.d.ts +86 -0
- package/lib/models/UserDTO.js +84 -0
- package/lib/models/index.d.ts +45 -4
- package/lib/models/index.js +45 -4
- package/lib/sdk/index.d.ts +5 -4
- package/lib/sdk/index.js +6 -5
- package/lib/services/DatalayerServiceManager.js +1 -1
- package/lib/state/substates/CoreState.js +2 -0
- package/lib/state/substates/RuntimesState.d.ts +1 -1
- package/lib/state/substates/RuntimesState.js +1 -1
- package/lib/{sdk/stateful → stateful}/index.d.ts +1 -1
- package/lib/{sdk/stateful → stateful}/index.js +1 -1
- package/lib/{sdk/stateful → stateful}/jupyter/exec/Snippets.d.ts +1 -41
- package/lib/{sdk/stateful → stateful}/jupyter/exec/Snippets.js +1 -20
- package/lib/{sdk/stateful → stateful}/runtimes/actions.d.ts +3 -3
- package/lib/{sdk/stateful → stateful}/runtimes/actions.js +8 -8
- package/lib/{sdk/stateful → stateful}/runtimes/apis.d.ts +8 -8
- package/package.json +13 -10
- package/lib/__tests__/hooks.test.d.ts +0 -1
- package/lib/__tests__/hooks.test.js +0 -19
- package/lib/__tests__/index.test.d.ts +0 -1
- package/lib/__tests__/index.test.js +0 -27
- package/lib/__tests__/integration.test.d.ts +0 -1
- package/lib/__tests__/integration.test.js +0 -57
- package/lib/__tests__/shared/cleanup-shared.d.ts +0 -4
- package/lib/__tests__/shared/cleanup-shared.js +0 -228
- package/lib/__tests__/shared/test-config.d.ts +0 -51
- package/lib/__tests__/shared/test-config.js +0 -110
- package/lib/__tests__/shared/test-constants.d.ts +0 -66
- package/lib/__tests__/shared/test-constants.js +0 -79
- package/lib/__tests__/utils.test.d.ts +0 -1
- package/lib/__tests__/utils.test.js +0 -59
- package/lib/api/__tests__/iam.authentication.integration.test.d.ts +0 -1
- package/lib/api/__tests__/iam.authentication.integration.test.js +0 -247
- package/lib/api/__tests__/iam.healthz.integration.test.d.ts +0 -1
- package/lib/api/__tests__/iam.healthz.integration.test.js +0 -63
- package/lib/api/__tests__/iam.profile.integration.test.d.ts +0 -1
- package/lib/api/__tests__/iam.profile.integration.test.js +0 -252
- package/lib/api/__tests__/runtimes.environments.integration.test.d.ts +0 -1
- package/lib/api/__tests__/runtimes.environments.integration.test.js +0 -122
- package/lib/api/__tests__/runtimes.healthz.integration.test.d.ts +0 -1
- package/lib/api/__tests__/runtimes.healthz.integration.test.js +0 -50
- package/lib/api/__tests__/runtimes.integration.test.d.ts +0 -1
- package/lib/api/__tests__/runtimes.integration.test.js +0 -369
- package/lib/api/__tests__/spacer.healthz.integration.test.d.ts +0 -1
- package/lib/api/__tests__/spacer.healthz.integration.test.js +0 -50
- package/lib/api/__tests__/spacer.integration.test.d.ts +0 -1
- package/lib/api/__tests__/spacer.integration.test.js +0 -519
- package/lib/api/iam/__tests__/authentication.unit.test.d.ts +0 -1
- package/lib/api/iam/__tests__/authentication.unit.test.js +0 -63
- package/lib/api/iam/__tests__/healthz.unit.test.d.ts +0 -1
- package/lib/api/iam/__tests__/healthz.unit.test.js +0 -60
- package/lib/api/iam/__tests__/profile.unit.test.d.ts +0 -1
- package/lib/api/iam/__tests__/profile.unit.test.js +0 -57
- package/lib/api/runtimes/__tests__/environments.unit.test.d.ts +0 -1
- package/lib/api/runtimes/__tests__/environments.unit.test.js +0 -77
- package/lib/api/runtimes/__tests__/healthz.unit.test.d.ts +0 -1
- package/lib/api/runtimes/__tests__/healthz.unit.test.js +0 -57
- package/lib/api/runtimes/__tests__/runtimes.unit.test.d.ts +0 -1
- package/lib/api/runtimes/__tests__/runtimes.unit.test.js +0 -139
- package/lib/api/runtimes/__tests__/snapshots.unit.test.d.ts +0 -1
- package/lib/api/runtimes/__tests__/snapshots.unit.test.js +0 -96
- package/lib/api/spacer/__tests__/healthz.unit.test.d.ts +0 -1
- package/lib/api/spacer/__tests__/healthz.unit.test.js +0 -57
- package/lib/api/spacer/__tests__/items.unit.test.d.ts +0 -1
- package/lib/api/spacer/__tests__/items.unit.test.js +0 -165
- package/lib/api/spacer/__tests__/lexicals.unit.test.d.ts +0 -1
- package/lib/api/spacer/__tests__/lexicals.unit.test.js +0 -323
- package/lib/api/spacer/__tests__/notebooks.unit.test.d.ts +0 -1
- package/lib/api/spacer/__tests__/notebooks.unit.test.js +0 -224
- package/lib/api/spacer/__tests__/users.unit.test.d.ts +0 -1
- package/lib/api/spacer/__tests__/users.unit.test.js +0 -132
- package/lib/api/types/index.d.ts +0 -32
- package/lib/api/types/index.js +0 -36
- package/lib/api/types/runtimes.d.ts +0 -235
- package/lib/api/types/spacer.d.ts +0 -271
- package/lib/api/types/spacer.js +0 -5
- package/lib/api/utils/__tests__/validation.test.d.ts +0 -1
- package/lib/api/utils/__tests__/validation.test.js +0 -109
- package/lib/sdk/client/__tests__/sdk.health.integration.test.d.ts +0 -1
- package/lib/sdk/client/__tests__/sdk.health.integration.test.js +0 -110
- package/lib/sdk/client/__tests__/sdk.iam.integration.test.d.ts +0 -1
- package/lib/sdk/client/__tests__/sdk.iam.integration.test.js +0 -179
- package/lib/sdk/client/__tests__/sdk.models.integration.test.d.ts +0 -1
- package/lib/sdk/client/__tests__/sdk.models.integration.test.js +0 -376
- package/lib/sdk/client/__tests__/sdk.runtimes.integration.test.d.ts +0 -1
- package/lib/sdk/client/__tests__/sdk.runtimes.integration.test.js +0 -276
- package/lib/sdk/client/__tests__/sdk.spacer.integration.test.d.ts +0 -1
- package/lib/sdk/client/__tests__/sdk.spacer.integration.test.js +0 -361
- package/lib/sdk/client/base.d.ts +0 -88
- package/lib/sdk/client/base.js +0 -112
- package/lib/sdk/client/index.d.ts +0 -192
- package/lib/sdk/client/index.js +0 -128
- package/lib/sdk/client/mixins/HealthMixin.d.ts +0 -100
- package/lib/sdk/client/mixins/HealthMixin.js +0 -133
- package/lib/sdk/client/mixins/IAMMixin.d.ts +0 -59
- package/lib/sdk/client/mixins/IAMMixin.js +0 -83
- package/lib/sdk/client/mixins/RuntimesMixin.d.ts +0 -134
- package/lib/sdk/client/mixins/RuntimesMixin.js +0 -221
- package/lib/sdk/client/mixins/SpacerMixin.d.ts +0 -184
- package/lib/sdk/client/mixins/SpacerMixin.js +0 -278
- package/lib/sdk/client/models/Lexical.d.ts +0 -156
- package/lib/sdk/client/models/Lexical.js +0 -275
- package/lib/sdk/client/models/Notebook.d.ts +0 -174
- package/lib/sdk/client/models/Notebook.js +0 -311
- package/lib/sdk/client/models/Runtime.d.ts +0 -221
- package/lib/sdk/client/models/Runtime.js +0 -341
- package/lib/sdk/client/models/Snapshot.d.ts +0 -156
- package/lib/sdk/client/models/Snapshot.js +0 -244
- package/lib/sdk/client/models/Space.d.ts +0 -182
- package/lib/sdk/client/models/Space.js +0 -276
- package/lib/sdk/client/models/__tests__/Lexical.test.d.ts +0 -1
- package/lib/sdk/client/models/__tests__/Lexical.test.js +0 -288
- package/lib/sdk/client/models/__tests__/Notebook.test.d.ts +0 -1
- package/lib/sdk/client/models/__tests__/Notebook.test.js +0 -206
- package/lib/sdk/client/models/__tests__/Runtime.test.d.ts +0 -1
- package/lib/sdk/client/models/__tests__/Runtime.test.js +0 -133
- package/lib/sdk/client/models/__tests__/Snapshot.test.d.ts +0 -1
- package/lib/sdk/client/models/__tests__/Snapshot.test.js +0 -244
- package/lib/sdk/client/models/__tests__/Space.test.d.ts +0 -1
- package/lib/sdk/client/models/__tests__/Space.test.js +0 -334
- package/lib/sdk/client/models/index.d.ts +0 -30
- package/lib/sdk/client/models/index.js +0 -30
- package/lib/sdk/client/utils/mixins.d.ts +0 -42
- /package/lib/{api/types/iam.js → models/Common.js} +0 -0
- /package/lib/{api/types/runtimes.js → models/IAM.js} +0 -0
- /package/lib/{sdk/stateful → stateful}/jupyter/exec/Python.d.ts +0 -0
- /package/lib/{sdk/stateful → stateful}/jupyter/exec/Python.js +0 -0
- /package/lib/{sdk/stateful → stateful}/jupyter/exec/index.d.ts +0 -0
- /package/lib/{sdk/stateful → stateful}/jupyter/exec/index.js +0 -0
- /package/lib/{sdk/stateful → stateful}/jupyter/index.d.ts +0 -0
- /package/lib/{sdk/stateful → stateful}/jupyter/index.js +0 -0
- /package/lib/{sdk/stateful → stateful}/jupyter/kernelsHandler.d.ts +0 -0
- /package/lib/{sdk/stateful → stateful}/jupyter/kernelsHandler.js +0 -0
- /package/lib/{sdk/stateful → stateful}/runtimes/apis.js +0 -0
- /package/lib/{sdk/stateful → stateful}/runtimes/index.d.ts +0 -0
- /package/lib/{sdk/stateful → stateful}/runtimes/index.js +0 -0
- /package/lib/{sdk/stateful → stateful}/runtimes/settings.d.ts +0 -0
- /package/lib/{sdk/stateful → stateful}/runtimes/settings.js +0 -0
- /package/lib/{sdk/stateful → stateful}/runtimes/snapshots.d.ts +0 -0
- /package/lib/{sdk/stateful → stateful}/runtimes/snapshots.js +0 -0
- /package/lib/{sdk/stateful → stateful}/runtimes/utils.d.ts +0 -0
- /package/lib/{sdk/stateful → stateful}/runtimes/utils.js +0 -0
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
-
* Distributed under the terms of the Modified BSD License.
|
|
4
|
-
*/
|
|
5
|
-
import { describe, it, expect } from 'vitest';
|
|
6
|
-
import { profile } from '..';
|
|
7
|
-
describe('IAM Profile Unit Tests', () => {
|
|
8
|
-
describe('parameter validation', () => {
|
|
9
|
-
it('should handle undefined token parameter at runtime', async () => {
|
|
10
|
-
console.log('Testing that undefined token is caught by validation...');
|
|
11
|
-
// In JavaScript/TypeScript at runtime, calling a function without
|
|
12
|
-
// required parameters just passes undefined for those parameters.
|
|
13
|
-
// Our validation code inside the function should catch this.
|
|
14
|
-
// Test me() with undefined token
|
|
15
|
-
await expect(profile.me(undefined)).rejects.toThrow('Authentication token is required');
|
|
16
|
-
// Test whoami() with undefined token
|
|
17
|
-
await expect(profile.whoami(undefined)).rejects.toThrow('Authentication token is required');
|
|
18
|
-
console.log('Validation correctly rejects undefined token');
|
|
19
|
-
});
|
|
20
|
-
it('should handle null token parameter at runtime', async () => {
|
|
21
|
-
console.log('Testing that null token is caught by validation...');
|
|
22
|
-
// Test me() with null token
|
|
23
|
-
await expect(profile.me(null)).rejects.toThrow('Authentication token is required');
|
|
24
|
-
// Test whoami() with null token
|
|
25
|
-
await expect(profile.whoami(null)).rejects.toThrow('Authentication token is required');
|
|
26
|
-
console.log('Validation correctly rejects null token');
|
|
27
|
-
});
|
|
28
|
-
it('should handle empty string token', async () => {
|
|
29
|
-
console.log('Testing that empty string token is caught by validation...');
|
|
30
|
-
// Test me() with empty string
|
|
31
|
-
await expect(profile.me('')).rejects.toThrow('Authentication token is required');
|
|
32
|
-
// Test whoami() with empty string
|
|
33
|
-
await expect(profile.whoami('')).rejects.toThrow('Authentication token is required');
|
|
34
|
-
console.log('Validation correctly rejects empty string token');
|
|
35
|
-
});
|
|
36
|
-
it('should handle whitespace-only token', async () => {
|
|
37
|
-
console.log('Testing that whitespace-only token is caught by validation...');
|
|
38
|
-
// Test me() with whitespace
|
|
39
|
-
await expect(profile.me(' ')).rejects.toThrow('Authentication token is required');
|
|
40
|
-
// Test whoami() with whitespace
|
|
41
|
-
await expect(profile.whoami(' ')).rejects.toThrow('Authentication token is required');
|
|
42
|
-
console.log('Validation correctly rejects whitespace-only token');
|
|
43
|
-
});
|
|
44
|
-
it('demonstrates JavaScript runtime behavior with missing parameters', () => {
|
|
45
|
-
console.log('Demonstrating JS runtime behavior...');
|
|
46
|
-
// This demonstrates that JavaScript doesn't throw errors for missing parameters
|
|
47
|
-
// The function receives undefined for missing parameters
|
|
48
|
-
function testFunction(required) {
|
|
49
|
-
return required === undefined;
|
|
50
|
-
}
|
|
51
|
-
// @ts-expect-error TypeScript knows this is wrong, but JS allows it
|
|
52
|
-
const result = testFunction();
|
|
53
|
-
expect(result).toBe(true); // The parameter is undefined
|
|
54
|
-
console.log('JavaScript passes undefined for missing parameters');
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
-
* Distributed under the terms of the Modified BSD License.
|
|
4
|
-
*/
|
|
5
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
6
|
-
import { environments } from '..';
|
|
7
|
-
import { requestDatalayerAPI } from '../../DatalayerApi';
|
|
8
|
-
import { MOCK_JWT_TOKEN, MOCK_ENVIRONMENTS_RESPONSE, } from '../../../__tests__/shared/test-constants';
|
|
9
|
-
// Mock the DatalayerAPI module
|
|
10
|
-
vi.mock('../../DatalayerApi');
|
|
11
|
-
describe('Runtimes Environments Unit Tests', () => {
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
vi.clearAllMocks();
|
|
14
|
-
});
|
|
15
|
-
describe('listEnvironments', () => {
|
|
16
|
-
it('should list environments with valid token', async () => {
|
|
17
|
-
vi.mocked(requestDatalayerAPI).mockResolvedValueOnce(MOCK_ENVIRONMENTS_RESPONSE);
|
|
18
|
-
const result = await environments.listEnvironments(MOCK_JWT_TOKEN);
|
|
19
|
-
expect(result).toEqual(MOCK_ENVIRONMENTS_RESPONSE);
|
|
20
|
-
expect(requestDatalayerAPI).toHaveBeenCalledWith({
|
|
21
|
-
url: 'https://prod1.datalayer.run/api/runtimes/v1/environments',
|
|
22
|
-
method: 'GET',
|
|
23
|
-
token: MOCK_JWT_TOKEN,
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
it('should use custom base URL when provided', async () => {
|
|
27
|
-
const mockResponse = {
|
|
28
|
-
success: true,
|
|
29
|
-
message: 'Environments retrieved',
|
|
30
|
-
environments: [],
|
|
31
|
-
};
|
|
32
|
-
const customUrl = 'https://staging.datalayer.run';
|
|
33
|
-
vi.mocked(requestDatalayerAPI).mockResolvedValueOnce(mockResponse);
|
|
34
|
-
const result = await environments.listEnvironments(MOCK_JWT_TOKEN, customUrl);
|
|
35
|
-
expect(result).toEqual(mockResponse);
|
|
36
|
-
expect(requestDatalayerAPI).toHaveBeenCalledWith({
|
|
37
|
-
url: `${customUrl}/api/runtimes/v1/environments`,
|
|
38
|
-
method: 'GET',
|
|
39
|
-
token: MOCK_JWT_TOKEN,
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
it('should throw error when token is missing', async () => {
|
|
43
|
-
await expect(environments.listEnvironments('')).rejects.toThrow('Authentication token is required');
|
|
44
|
-
expect(requestDatalayerAPI).not.toHaveBeenCalled();
|
|
45
|
-
});
|
|
46
|
-
it('should throw error when token is null', async () => {
|
|
47
|
-
// @ts-expect-error Testing null token
|
|
48
|
-
await expect(environments.listEnvironments(null)).rejects.toThrow('Authentication token is required');
|
|
49
|
-
expect(requestDatalayerAPI).not.toHaveBeenCalled();
|
|
50
|
-
});
|
|
51
|
-
it('should throw error when token is undefined', async () => {
|
|
52
|
-
// @ts-expect-error Testing undefined token
|
|
53
|
-
await expect(environments.listEnvironments(undefined)).rejects.toThrow('Authentication token is required');
|
|
54
|
-
expect(requestDatalayerAPI).not.toHaveBeenCalled();
|
|
55
|
-
});
|
|
56
|
-
it('should throw error when token is only whitespace', async () => {
|
|
57
|
-
await expect(environments.listEnvironments(' ')).rejects.toThrow('Authentication token is required');
|
|
58
|
-
expect(requestDatalayerAPI).not.toHaveBeenCalled();
|
|
59
|
-
});
|
|
60
|
-
it('should handle API errors properly', async () => {
|
|
61
|
-
const mockError = new Error('Network error');
|
|
62
|
-
vi.mocked(requestDatalayerAPI).mockRejectedValueOnce(mockError);
|
|
63
|
-
await expect(environments.listEnvironments(MOCK_JWT_TOKEN)).rejects.toThrow('Network error');
|
|
64
|
-
});
|
|
65
|
-
it('should handle empty environments list', async () => {
|
|
66
|
-
const mockResponse = {
|
|
67
|
-
success: true,
|
|
68
|
-
message: 'No environments available',
|
|
69
|
-
environments: [],
|
|
70
|
-
};
|
|
71
|
-
vi.mocked(requestDatalayerAPI).mockResolvedValueOnce(mockResponse);
|
|
72
|
-
const result = await environments.listEnvironments(MOCK_JWT_TOKEN);
|
|
73
|
-
expect(result).toEqual(mockResponse);
|
|
74
|
-
expect(result.environments).toHaveLength(0);
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
-
* Distributed under the terms of the Modified BSD License.
|
|
4
|
-
*/
|
|
5
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
6
|
-
import { healthz } from '..';
|
|
7
|
-
import { requestDatalayerAPI } from '../../DatalayerApi';
|
|
8
|
-
// Mock the DatalayerAPI module
|
|
9
|
-
vi.mock('../../DatalayerApi');
|
|
10
|
-
describe('Runtimes Healthz Unit Tests', () => {
|
|
11
|
-
beforeEach(() => {
|
|
12
|
-
vi.clearAllMocks();
|
|
13
|
-
});
|
|
14
|
-
describe('ping', () => {
|
|
15
|
-
it('should successfully ping the service', async () => {
|
|
16
|
-
const mockResponse = {
|
|
17
|
-
success: true,
|
|
18
|
-
message: 'Runtimes service is healthy',
|
|
19
|
-
status: {
|
|
20
|
-
status: 'OK',
|
|
21
|
-
},
|
|
22
|
-
version: '1.0.0',
|
|
23
|
-
};
|
|
24
|
-
vi.mocked(requestDatalayerAPI).mockResolvedValueOnce(mockResponse);
|
|
25
|
-
const result = await healthz.ping('https://test.datalayer.run');
|
|
26
|
-
expect(result).toEqual(mockResponse);
|
|
27
|
-
expect(requestDatalayerAPI).toHaveBeenCalledWith({
|
|
28
|
-
url: 'https://test.datalayer.run/api/runtimes/v1/ping',
|
|
29
|
-
method: 'GET',
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
it('should use default URL when not provided', async () => {
|
|
33
|
-
const mockResponse = {
|
|
34
|
-
success: true,
|
|
35
|
-
message: 'Service is healthy',
|
|
36
|
-
};
|
|
37
|
-
vi.mocked(requestDatalayerAPI).mockResolvedValueOnce(mockResponse);
|
|
38
|
-
const result = await healthz.ping();
|
|
39
|
-
expect(result).toEqual(mockResponse);
|
|
40
|
-
expect(requestDatalayerAPI).toHaveBeenCalledWith({
|
|
41
|
-
url: 'https://prod1.datalayer.run/api/runtimes/v1/ping',
|
|
42
|
-
method: 'GET',
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
it('should handle service unhealthy errors', async () => {
|
|
46
|
-
const mockError = new Error('Service error');
|
|
47
|
-
mockError.response = { status: 500 };
|
|
48
|
-
vi.mocked(requestDatalayerAPI).mockRejectedValueOnce(mockError);
|
|
49
|
-
await expect(healthz.ping()).rejects.toThrow('Health check failed: Service unhealthy (status 500)');
|
|
50
|
-
});
|
|
51
|
-
it('should handle network errors', async () => {
|
|
52
|
-
const mockError = new Error('Network error');
|
|
53
|
-
vi.mocked(requestDatalayerAPI).mockRejectedValueOnce(mockError);
|
|
54
|
-
await expect(healthz.ping()).rejects.toThrow('Health check failed: Network error');
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
-
* Distributed under the terms of the Modified BSD License.
|
|
4
|
-
*/
|
|
5
|
-
import { describe, it, expect } from 'vitest';
|
|
6
|
-
import { runtimes } from '..';
|
|
7
|
-
import { MOCK_JWT_TOKEN } from '../../../__tests__/shared/test-constants';
|
|
8
|
-
describe('Runtimes Unit Tests', () => {
|
|
9
|
-
describe('create parameter validation', () => {
|
|
10
|
-
const mockBaseUrl = 'https://example.com';
|
|
11
|
-
const mockData = {
|
|
12
|
-
environment_name: 'python-cpu-env',
|
|
13
|
-
type: 'notebook',
|
|
14
|
-
given_name: 'test-runtime',
|
|
15
|
-
credits_limit: 100,
|
|
16
|
-
};
|
|
17
|
-
it('should fail when token is missing', async () => {
|
|
18
|
-
console.log('Testing create with missing token...');
|
|
19
|
-
await expect(
|
|
20
|
-
// @ts-expect-error Testing undefined token
|
|
21
|
-
runtimes.createRuntime(undefined, mockData, mockBaseUrl)).rejects.toThrow('Authentication token is required');
|
|
22
|
-
console.log('Correctly rejected create with missing token');
|
|
23
|
-
});
|
|
24
|
-
it('should fail when token is empty', async () => {
|
|
25
|
-
console.log('Testing create with empty token...');
|
|
26
|
-
await expect(runtimes.createRuntime('', mockData, mockBaseUrl)).rejects.toThrow('Authentication token is required');
|
|
27
|
-
console.log('Correctly rejected create with empty token');
|
|
28
|
-
});
|
|
29
|
-
it('should fail when token is only whitespace', async () => {
|
|
30
|
-
console.log('Testing create with whitespace token...');
|
|
31
|
-
await expect(runtimes.createRuntime(' ', mockData, mockBaseUrl)).rejects.toThrow('Authentication token is required');
|
|
32
|
-
console.log('Correctly rejected create with whitespace token');
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
describe('list parameter validation', () => {
|
|
36
|
-
const mockBaseUrl = 'https://example.com';
|
|
37
|
-
it('should fail when token is missing', async () => {
|
|
38
|
-
console.log('Testing list with missing token...');
|
|
39
|
-
await expect(
|
|
40
|
-
// @ts-expect-error Testing undefined token
|
|
41
|
-
runtimes.listRuntimes(undefined, mockBaseUrl)).rejects.toThrow('Authentication token is required');
|
|
42
|
-
console.log('Correctly rejected list with missing token');
|
|
43
|
-
});
|
|
44
|
-
it('should fail when token is null', async () => {
|
|
45
|
-
console.log('Testing list with null token...');
|
|
46
|
-
await expect(
|
|
47
|
-
// @ts-expect-error Testing null token
|
|
48
|
-
runtimes.listRuntimes(null, mockBaseUrl)).rejects.toThrow('Authentication token is required');
|
|
49
|
-
console.log('Correctly rejected list with null token');
|
|
50
|
-
});
|
|
51
|
-
it('should fail when token is empty', async () => {
|
|
52
|
-
console.log('Testing list with empty token...');
|
|
53
|
-
await expect(runtimes.listRuntimes('', mockBaseUrl)).rejects.toThrow('Authentication token is required');
|
|
54
|
-
console.log('Correctly rejected list with empty token');
|
|
55
|
-
});
|
|
56
|
-
it('should fail when token is only whitespace', async () => {
|
|
57
|
-
console.log('Testing list with whitespace token...');
|
|
58
|
-
await expect(runtimes.listRuntimes(' ', mockBaseUrl)).rejects.toThrow('Authentication token is required');
|
|
59
|
-
console.log('Correctly rejected list with whitespace token');
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
describe('get parameter validation', () => {
|
|
63
|
-
const mockBaseUrl = 'https://example.com';
|
|
64
|
-
it('should fail when token is missing', async () => {
|
|
65
|
-
console.log('Testing get with missing token...');
|
|
66
|
-
await expect(
|
|
67
|
-
// @ts-expect-error Testing undefined token
|
|
68
|
-
runtimes.getRuntime(undefined, 'pod-123', mockBaseUrl)).rejects.toThrow('Authentication token is required');
|
|
69
|
-
console.log('Correctly rejected get with missing token');
|
|
70
|
-
});
|
|
71
|
-
it('should fail when pod name is missing', async () => {
|
|
72
|
-
console.log('Testing get with missing pod name...');
|
|
73
|
-
await expect(
|
|
74
|
-
// @ts-expect-error Testing undefined pod name
|
|
75
|
-
runtimes.getRuntime(MOCK_JWT_TOKEN, undefined, mockBaseUrl)).rejects.toThrow('Pod name is required');
|
|
76
|
-
console.log('Correctly rejected get with missing pod name');
|
|
77
|
-
});
|
|
78
|
-
it('should fail when pod name is empty', async () => {
|
|
79
|
-
console.log('Testing get with empty pod name...');
|
|
80
|
-
await expect(runtimes.getRuntime(MOCK_JWT_TOKEN, '', mockBaseUrl)).rejects.toThrow('Pod name is required');
|
|
81
|
-
console.log('Correctly rejected get with empty pod name');
|
|
82
|
-
});
|
|
83
|
-
it('should fail when pod name is only whitespace', async () => {
|
|
84
|
-
console.log('Testing get with whitespace pod name...');
|
|
85
|
-
await expect(runtimes.getRuntime(MOCK_JWT_TOKEN, ' ', mockBaseUrl)).rejects.toThrow('Pod name is required');
|
|
86
|
-
console.log('Correctly rejected get with whitespace pod name');
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
describe('remove parameter validation', () => {
|
|
90
|
-
const mockBaseUrl = 'https://example.com';
|
|
91
|
-
it('should fail when token is missing', async () => {
|
|
92
|
-
console.log('Testing remove with missing token...');
|
|
93
|
-
await expect(
|
|
94
|
-
// @ts-expect-error Testing undefined token
|
|
95
|
-
runtimes.deleteRuntime(undefined, 'pod-123', mockBaseUrl)).rejects.toThrow('Authentication token is required');
|
|
96
|
-
console.log('Correctly rejected remove with missing token');
|
|
97
|
-
});
|
|
98
|
-
it('should fail when pod name is missing', async () => {
|
|
99
|
-
console.log('Testing remove with missing pod name...');
|
|
100
|
-
await expect(
|
|
101
|
-
// @ts-expect-error Testing undefined pod name
|
|
102
|
-
runtimes.deleteRuntime(MOCK_JWT_TOKEN, undefined, mockBaseUrl)).rejects.toThrow('Pod name is required');
|
|
103
|
-
console.log('Correctly rejected remove with missing pod name');
|
|
104
|
-
});
|
|
105
|
-
it('should fail when pod name is empty', async () => {
|
|
106
|
-
console.log('Testing remove with empty pod name...');
|
|
107
|
-
await expect(runtimes.deleteRuntime(MOCK_JWT_TOKEN, '', mockBaseUrl)).rejects.toThrow('Pod name is required');
|
|
108
|
-
console.log('Correctly rejected remove with empty pod name');
|
|
109
|
-
});
|
|
110
|
-
it('should fail when pod name is only whitespace', async () => {
|
|
111
|
-
console.log('Testing remove with whitespace pod name...');
|
|
112
|
-
await expect(runtimes.deleteRuntime(MOCK_JWT_TOKEN, ' ', mockBaseUrl)).rejects.toThrow('Pod name is required');
|
|
113
|
-
console.log('Correctly rejected remove with whitespace pod name');
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
describe('put parameter validation', () => {
|
|
117
|
-
const mockBaseUrl = 'https://example.com';
|
|
118
|
-
it('should fail when token is missing', async () => {
|
|
119
|
-
console.log('Testing put with missing token...');
|
|
120
|
-
await expect(runtimes.updateRuntime(undefined, 'pod-123', 'snapshot-123', mockBaseUrl)).rejects.toThrow('Authentication token is required');
|
|
121
|
-
console.log('Correctly rejected put with missing token');
|
|
122
|
-
});
|
|
123
|
-
it('should fail when pod name is missing', async () => {
|
|
124
|
-
console.log('Testing put with missing pod name...');
|
|
125
|
-
await expect(runtimes.updateRuntime(MOCK_JWT_TOKEN, undefined, 'snapshot-123', mockBaseUrl)).rejects.toThrow('Pod name is required');
|
|
126
|
-
console.log('Correctly rejected put with missing pod name');
|
|
127
|
-
});
|
|
128
|
-
it('should fail when pod name is empty', async () => {
|
|
129
|
-
console.log('Testing put with empty pod name...');
|
|
130
|
-
await expect(runtimes.updateRuntime(MOCK_JWT_TOKEN, '', 'snapshot-123', mockBaseUrl)).rejects.toThrow('Pod name is required');
|
|
131
|
-
console.log('Correctly rejected put with empty pod name');
|
|
132
|
-
});
|
|
133
|
-
it('should fail when pod name is only whitespace', async () => {
|
|
134
|
-
console.log('Testing put with whitespace pod name...');
|
|
135
|
-
await expect(runtimes.updateRuntime(MOCK_JWT_TOKEN, ' ', 'snapshot-123', mockBaseUrl)).rejects.toThrow('Pod name is required');
|
|
136
|
-
console.log('Correctly rejected put with whitespace pod name');
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
-
* Distributed under the terms of the Modified BSD License.
|
|
4
|
-
*/
|
|
5
|
-
import { describe, it, expect } from 'vitest';
|
|
6
|
-
import { snapshots } from '..';
|
|
7
|
-
import { MOCK_JWT_TOKEN } from '../../../__tests__/shared/test-constants';
|
|
8
|
-
describe('Runtimes Snapshots Unit Tests', () => {
|
|
9
|
-
describe('create parameter validation', () => {
|
|
10
|
-
const mockBaseUrl = 'https://example.com';
|
|
11
|
-
const mockData = {
|
|
12
|
-
pod_name: 'pod-123',
|
|
13
|
-
name: 'my-snapshot',
|
|
14
|
-
description: 'Test snapshot',
|
|
15
|
-
stop: true,
|
|
16
|
-
};
|
|
17
|
-
it('should fail when token is missing', async () => {
|
|
18
|
-
console.log('Testing create with missing token...');
|
|
19
|
-
await expect(
|
|
20
|
-
// @ts-expect-error Testing undefined token
|
|
21
|
-
snapshots.createSnapshot(undefined, mockData, mockBaseUrl)).rejects.toThrow('Authentication token is required');
|
|
22
|
-
console.log('Correctly rejected create with missing token');
|
|
23
|
-
});
|
|
24
|
-
it('should fail when token is empty', async () => {
|
|
25
|
-
console.log('Testing create with empty token...');
|
|
26
|
-
await expect(snapshots.createSnapshot('', mockData, mockBaseUrl)).rejects.toThrow('Authentication token is required');
|
|
27
|
-
console.log('Correctly rejected create with empty token');
|
|
28
|
-
});
|
|
29
|
-
it('should fail when token is only whitespace', async () => {
|
|
30
|
-
console.log('Testing create with whitespace token...');
|
|
31
|
-
await expect(snapshots.createSnapshot(' ', mockData, mockBaseUrl)).rejects.toThrow('Authentication token is required');
|
|
32
|
-
console.log('Correctly rejected create with whitespace token');
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
describe('list parameter validation', () => {
|
|
36
|
-
const mockBaseUrl = 'https://example.com';
|
|
37
|
-
it('should fail when token is missing', async () => {
|
|
38
|
-
console.log('Testing list with missing token...');
|
|
39
|
-
await expect(
|
|
40
|
-
// @ts-expect-error Testing undefined token
|
|
41
|
-
snapshots.listSnapshots(undefined, mockBaseUrl)).rejects.toThrow('Authentication token is required');
|
|
42
|
-
console.log('Correctly rejected list with missing token');
|
|
43
|
-
});
|
|
44
|
-
it('should fail when token is null', async () => {
|
|
45
|
-
console.log('Testing list with null token...');
|
|
46
|
-
await expect(
|
|
47
|
-
// @ts-expect-error Testing null token
|
|
48
|
-
snapshots.listSnapshots(null, mockBaseUrl)).rejects.toThrow('Authentication token is required');
|
|
49
|
-
console.log('Correctly rejected list with null token');
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
describe('get parameter validation', () => {
|
|
53
|
-
const mockBaseUrl = 'https://example.com';
|
|
54
|
-
it('should fail when token is missing', async () => {
|
|
55
|
-
console.log('Testing get with missing token...');
|
|
56
|
-
await expect(
|
|
57
|
-
// @ts-expect-error Testing undefined token
|
|
58
|
-
snapshots.getSnapshot(undefined, 'snapshot-123', mockBaseUrl)).rejects.toThrow('Authentication token is required');
|
|
59
|
-
console.log('Correctly rejected get with missing token');
|
|
60
|
-
});
|
|
61
|
-
it('should fail when snapshot ID is missing', async () => {
|
|
62
|
-
console.log('Testing get with missing snapshot ID...');
|
|
63
|
-
await expect(
|
|
64
|
-
// @ts-expect-error Testing undefined snapshot ID
|
|
65
|
-
snapshots.getSnapshot(MOCK_JWT_TOKEN, undefined, mockBaseUrl)).rejects.toThrow('Snapshot ID is required');
|
|
66
|
-
console.log('Correctly rejected get with missing snapshot ID');
|
|
67
|
-
});
|
|
68
|
-
it('should fail when snapshot ID is empty', async () => {
|
|
69
|
-
console.log('Testing get with empty snapshot ID...');
|
|
70
|
-
await expect(snapshots.getSnapshot(MOCK_JWT_TOKEN, '', mockBaseUrl)).rejects.toThrow('Snapshot ID is required');
|
|
71
|
-
console.log('Correctly rejected get with empty snapshot ID');
|
|
72
|
-
});
|
|
73
|
-
it('should fail when snapshot ID is only whitespace', async () => {
|
|
74
|
-
console.log('Testing get with whitespace snapshot ID...');
|
|
75
|
-
await expect(snapshots.getSnapshot(MOCK_JWT_TOKEN, ' ', mockBaseUrl)).rejects.toThrow('Snapshot ID is required');
|
|
76
|
-
console.log('Correctly rejected get with whitespace snapshot ID');
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
describe('remove parameter validation', () => {
|
|
80
|
-
const mockBaseUrl = 'https://example.com';
|
|
81
|
-
it('should fail when token is missing', async () => {
|
|
82
|
-
console.log('Testing remove with missing token...');
|
|
83
|
-
await expect(
|
|
84
|
-
// @ts-expect-error Testing undefined token
|
|
85
|
-
snapshots.deleteSnapshot(undefined, 'snapshot-123', mockBaseUrl)).rejects.toThrow('Authentication token is required');
|
|
86
|
-
console.log('Correctly rejected remove with missing token');
|
|
87
|
-
});
|
|
88
|
-
it('should fail when snapshot ID is missing', async () => {
|
|
89
|
-
console.log('Testing remove with missing snapshot ID...');
|
|
90
|
-
await expect(
|
|
91
|
-
// @ts-expect-error Testing undefined snapshot ID
|
|
92
|
-
snapshots.deleteSnapshot(MOCK_JWT_TOKEN, undefined, mockBaseUrl)).rejects.toThrow('Snapshot ID is required');
|
|
93
|
-
console.log('Correctly rejected remove with missing snapshot ID');
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
-
* Distributed under the terms of the Modified BSD License.
|
|
4
|
-
*/
|
|
5
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
6
|
-
import { healthz } from '..';
|
|
7
|
-
import { requestDatalayerAPI } from '../../DatalayerApi';
|
|
8
|
-
// Mock the DatalayerAPI module
|
|
9
|
-
vi.mock('../../DatalayerApi');
|
|
10
|
-
describe('Spacer Healthz Unit Tests', () => {
|
|
11
|
-
beforeEach(() => {
|
|
12
|
-
vi.clearAllMocks();
|
|
13
|
-
});
|
|
14
|
-
describe('ping', () => {
|
|
15
|
-
it('should successfully ping the service', async () => {
|
|
16
|
-
const mockResponse = {
|
|
17
|
-
success: true,
|
|
18
|
-
message: 'Spacer service is healthy',
|
|
19
|
-
status: {
|
|
20
|
-
status: 'OK',
|
|
21
|
-
},
|
|
22
|
-
version: '1.0.0',
|
|
23
|
-
};
|
|
24
|
-
vi.mocked(requestDatalayerAPI).mockResolvedValueOnce(mockResponse);
|
|
25
|
-
const result = await healthz.ping('https://test.datalayer.run');
|
|
26
|
-
expect(result).toEqual(mockResponse);
|
|
27
|
-
expect(requestDatalayerAPI).toHaveBeenCalledWith({
|
|
28
|
-
url: 'https://test.datalayer.run/api/spacer/v1/ping',
|
|
29
|
-
method: 'GET',
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
it('should use default URL when not provided', async () => {
|
|
33
|
-
const mockResponse = {
|
|
34
|
-
success: true,
|
|
35
|
-
message: 'Service is healthy',
|
|
36
|
-
};
|
|
37
|
-
vi.mocked(requestDatalayerAPI).mockResolvedValueOnce(mockResponse);
|
|
38
|
-
const result = await healthz.ping();
|
|
39
|
-
expect(result).toEqual(mockResponse);
|
|
40
|
-
expect(requestDatalayerAPI).toHaveBeenCalledWith({
|
|
41
|
-
url: 'https://prod1.datalayer.run/api/spacer/v1/ping',
|
|
42
|
-
method: 'GET',
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
it('should handle service unhealthy errors', async () => {
|
|
46
|
-
const mockError = new Error('Service error');
|
|
47
|
-
mockError.response = { status: 500 };
|
|
48
|
-
vi.mocked(requestDatalayerAPI).mockRejectedValueOnce(mockError);
|
|
49
|
-
await expect(healthz.ping()).rejects.toThrow('Health check failed: Service unhealthy (status 500)');
|
|
50
|
-
});
|
|
51
|
-
it('should handle network errors', async () => {
|
|
52
|
-
const mockError = new Error('Network error');
|
|
53
|
-
vi.mocked(requestDatalayerAPI).mockRejectedValueOnce(mockError);
|
|
54
|
-
await expect(healthz.ping()).rejects.toThrow('Health check failed: Network error');
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|