@checkstack/backend 0.15.0 → 0.16.1
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/CHANGELOG.md +182 -0
- package/package.json +22 -22
- package/src/index.ts +102 -6
- package/src/plugin-manager/api-router.ts +47 -8
- package/src/plugin-manager/app-principal-authz.test.ts +178 -0
- package/src/plugin-manager/auth-passthrough.test.ts +259 -0
- package/src/plugin-manager/core-services.ts +78 -0
- package/src/plugin-manager/pg-http-errors.test.ts +65 -0
- package/src/plugin-manager/pg-http-errors.ts +85 -0
- package/src/plugin-manager/plugin-loader.getservice.test.ts +38 -0
- package/src/plugin-manager/plugin-loader.skip-naming.test.ts +115 -0
- package/src/plugin-manager/plugin-loader.ts +64 -5
- package/src/plugin-manager.ts +5 -1
- package/src/services/collector-registry.ts +9 -0
- package/src/services/dev-auth.test.ts +71 -9
- package/src/services/dev-auth.ts +42 -5
- package/src/services/health-check-registry.test.ts +34 -0
- package/src/services/health-check-registry.ts +7 -0
- package/src/services/service-registry.test.ts +60 -0
- package/src/utils/plugin-discovery.test.ts +29 -4
|
@@ -1,28 +1,53 @@
|
|
|
1
|
-
import { describe, it, expect, beforeEach, mock } from "bun:test";
|
|
1
|
+
import { describe, it, expect, beforeEach, afterAll, mock } from "bun:test";
|
|
2
2
|
import {
|
|
3
3
|
extractPluginMetadata,
|
|
4
4
|
discoverLocalPlugins,
|
|
5
5
|
syncPluginsToDatabase,
|
|
6
6
|
type PluginMetadata,
|
|
7
7
|
} from "./plugin-discovery";
|
|
8
|
+
import * as realFs from "node:fs";
|
|
8
9
|
import fs from "node:fs";
|
|
9
10
|
import path from "node:path";
|
|
10
11
|
|
|
11
|
-
// Mock filesystem for testing
|
|
12
|
+
// Mock filesystem for testing.
|
|
13
|
+
//
|
|
14
|
+
// `mock.module("node:fs", …)` is PROCESS-GLOBAL in bun and is NOT undone by
|
|
15
|
+
// `mock.restore()`, so a partial stub would leak the broken module to every
|
|
16
|
+
// fs-using test that sorts after this file (e.g. the scaffold tests that call
|
|
17
|
+
// `mkdtempSync`/`statSync`/`writeFileSync`). Two safeguards:
|
|
18
|
+
// 1. The stub spreads the REAL module and overrides only the three functions
|
|
19
|
+
// these tests assert on — so even while active, every other fs API works.
|
|
20
|
+
// 2. `afterAll` re-mocks `node:fs` back to the pristine real module, undoing
|
|
21
|
+
// the override for subsequently-loaded test files.
|
|
22
|
+
// Named exports (namespace) and the default export, captured before mocking.
|
|
23
|
+
const realFsModule: typeof realFs = { ...realFs };
|
|
24
|
+
const realFsDefault = fs;
|
|
25
|
+
|
|
12
26
|
const mockExistsSync = mock(() => true);
|
|
13
27
|
const mockReadFileSync = mock(() => "{}");
|
|
14
28
|
const mockReaddirSync = mock(() => []);
|
|
15
29
|
|
|
16
|
-
|
|
30
|
+
function mockFsModule() {
|
|
17
31
|
const exports = {
|
|
32
|
+
...realFsModule,
|
|
18
33
|
existsSync: mockExistsSync,
|
|
19
34
|
readFileSync: mockReadFileSync,
|
|
20
35
|
readdirSync: mockReaddirSync,
|
|
21
36
|
};
|
|
22
37
|
return {
|
|
23
38
|
...exports,
|
|
24
|
-
default: exports,
|
|
39
|
+
default: { ...realFsDefault, ...exports },
|
|
25
40
|
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
mock.module("node:fs", mockFsModule);
|
|
44
|
+
|
|
45
|
+
afterAll(() => {
|
|
46
|
+
// Restore the pristine fs module so later test files don't inherit the stub.
|
|
47
|
+
mock.module("node:fs", () => ({
|
|
48
|
+
...realFsModule,
|
|
49
|
+
default: realFsDefault,
|
|
50
|
+
}));
|
|
26
51
|
});
|
|
27
52
|
|
|
28
53
|
describe("extractPluginMetadata", () => {
|