@cobol-ts/cursor-loader-test 0.0.0-stage → 0.0.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/README.md +179 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +18 -0
- package/package.json +69 -3
package/README.md
CHANGED
|
@@ -1,3 +1,180 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @cobol-ts/cursor-loader-test
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Cross-package integration tests and shared application projections for the current `@cobol-ts` cursor-loader stack.
|
|
4
|
+
|
|
5
|
+
This package verifies that the separately tested packages agree on their shared contracts when used through the normal `@cobol-ts/cursor-file` orchestration path.
|
|
6
|
+
|
|
7
|
+
## Fixed-record COBOL consumer API
|
|
8
|
+
|
|
9
|
+
The AWS FB/150 integration suite exercises the public Node.js entry point:
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import {readCobolFile} from '@cobol-ts/cursor-loader-cobol/node';
|
|
13
|
+
|
|
14
|
+
for await (const record of readCobolFile({copybook, filename, projection, bufferSize: 3})) {
|
|
15
|
+
try { console.log(record.result.id()); }
|
|
16
|
+
finally { record.close(); }
|
|
17
|
+
}
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
The reader compiles the original copybook and projection, opens the real binary
|
|
21
|
+
file and streams borrowed views. No parser registry, record-state factory or
|
|
22
|
+
file-handle callback appears in the test. The AWS EBCDIC bytes and CSV oracle
|
|
23
|
+
are external published fixtures, not output from our encoder. The 3-byte read
|
|
24
|
+
case forces fields across multiple physical buffers without assembling them.
|
|
25
|
+
|
|
26
|
+
## Current integration path
|
|
27
|
+
|
|
28
|
+
The JSONL, CSV and COBOL integration suites use the same architecture:
|
|
29
|
+
|
|
30
|
+
```text
|
|
31
|
+
fixture bytes
|
|
32
|
+
↓
|
|
33
|
+
test file object with current offset
|
|
34
|
+
↓
|
|
35
|
+
FileCursorInfrastructure.fillFileBuffer
|
|
36
|
+
↓
|
|
37
|
+
@cobol-ts/cursor-file
|
|
38
|
+
↓
|
|
39
|
+
@cobol-ts/cursor-record
|
|
40
|
+
├── pooled byte buffers
|
|
41
|
+
├── pooled physical-record holders
|
|
42
|
+
└── optional parser preparation
|
|
43
|
+
↓
|
|
44
|
+
format parser
|
|
45
|
+
├── recognizes its own physical records
|
|
46
|
+
└── establishes endByte
|
|
47
|
+
↓
|
|
48
|
+
source-scoped projection compilation
|
|
49
|
+
↓
|
|
50
|
+
pooled FileCursorResult + reusable projection
|
|
51
|
+
↓
|
|
52
|
+
application values
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The JSONL/CSV fixture helpers load data into an in-memory `bytes + offset` source for deterministic physical-buffer tests. The AWS COBOL tests instead use `readCobolFile` and actual Node filesystem I/O.
|
|
56
|
+
|
|
57
|
+
The tests therefore exercise the production cursor-record, parser, projection and cursor-file contracts while keeping OS-specific streaming I/O outside the scope of this package.
|
|
58
|
+
|
|
59
|
+
There is no generic line reader or newline boundary detector in the current architecture.
|
|
60
|
+
|
|
61
|
+
## Shared application projections
|
|
62
|
+
|
|
63
|
+
`src/cursor.loader.fixture.ts` defines the shared application-facing projections used by both JSON and CSV integration tests.
|
|
64
|
+
|
|
65
|
+
The full `Customer` projection includes nested JSON paths such as address fields.
|
|
66
|
+
|
|
67
|
+
CSV uses its own canonical projection with flat header names for those same application accessors.
|
|
68
|
+
|
|
69
|
+
A `MinimalCustomer` projection deliberately accesses only a subset of fields, demonstrating that the same physical source can support different application views.
|
|
70
|
+
|
|
71
|
+
## JSONL integration coverage
|
|
72
|
+
|
|
73
|
+
The JSONL suite covers:
|
|
74
|
+
|
|
75
|
+
- complete customer records and nested projection paths;
|
|
76
|
+
- a second projection over the same source records;
|
|
77
|
+
- malformed JSON returned as recoverable row `Errors` with continuation;
|
|
78
|
+
- pooled projection rebinding;
|
|
79
|
+
- lazy projection errors reporting the **current** record after rebinding;
|
|
80
|
+
- `createErrorsOrFileCursor` row-error behaviour;
|
|
81
|
+
- `createThrowingFileCursor` row-error behaviour;
|
|
82
|
+
- `createIgnoringFileCursor` callbacks and continuation.
|
|
83
|
+
|
|
84
|
+
The lazy-error test verifies the fully composed diagnostic, including:
|
|
85
|
+
|
|
86
|
+
```text
|
|
87
|
+
filename
|
|
88
|
+
record number
|
|
89
|
+
logical projection path
|
|
90
|
+
JSON-specific type/value reason
|
|
91
|
+
physical JSON record
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## CSV integration coverage
|
|
95
|
+
|
|
96
|
+
The CSV suite covers:
|
|
97
|
+
|
|
98
|
+
- ordinary comma-separated customers;
|
|
99
|
+
- quoted fields containing commas;
|
|
100
|
+
- doubled quotes;
|
|
101
|
+
- empty fields;
|
|
102
|
+
- quoted numeric values;
|
|
103
|
+
- a different projection over the same CSV records;
|
|
104
|
+
- source-specific separator configuration through the file definition/registry;
|
|
105
|
+
- physical row-width mismatch returned as recoverable row `Errors` and continuation;
|
|
106
|
+
- missing projected header columns as setup failures with header provenance and available columns;
|
|
107
|
+
- malformed quoted input proving that a newline inside a quoted field is not treated as a record boundary.
|
|
108
|
+
|
|
109
|
+
The tests use small physical buffer sizes specifically to force parser behaviour across pooled buffer boundaries.
|
|
110
|
+
|
|
111
|
+
## COBOL integration coverage (AWS EMPREC01, FB/150)
|
|
112
|
+
|
|
113
|
+
`src/cursor.loader.cobol.aws.int.test.ts` uses fixtures in
|
|
114
|
+
`fixtures/aws-employee/`: a complete five-record 750-byte binary source,
|
|
115
|
+
the original EMPREC01 copybook and the upstream expected CSV values. The binary
|
|
116
|
+
is transcribed from the published upstream hex dump, **not** encoded using our
|
|
117
|
+
library, and its first record was independently checked against the already
|
|
118
|
+
established layout fixture. See the fixture README for attribution and SHA-256.
|
|
119
|
+
|
|
120
|
+
- Real copybook parsing and storage compilation feed `createCobolDecodedFixedDetails`.
|
|
121
|
+
- The public COBOL parser, record state and projection API are exercised via
|
|
122
|
+
`createFileCursor`, not by calling a decoder on standalone bytes.
|
|
123
|
+
- Every published employee field is compared across **all five records**:
|
|
124
|
+
`REDEFINES` ID interpretations, three `OCCURS` address lines, CP037 text,
|
|
125
|
+
signed DISPLAY, COMP, COMP-3, implied decimals and negative values. The
|
|
126
|
+
published CSV preserves padding and leading zeroes so these are checked too.
|
|
127
|
+
- Five deliberately different physical read sizes (3, 7, 149, 150 and 4096)
|
|
128
|
+
must produce identical values. This includes fragmentation **within** numeric
|
|
129
|
+
fields, array bodies and records. The codec never assembles field bytes.
|
|
130
|
+
- One test reads from a real filesystem handle with 11-byte reads, and one
|
|
131
|
+
retains two simultaneously live records and verifies closing one does not
|
|
132
|
+
corrupt the other; subsequent records are also verified after pool reuse.
|
|
133
|
+
|
|
134
|
+
No network requests are made by these tests. The golden output comes from AWS,
|
|
135
|
+
not from running an in-project encoder or writer. The independent AWS example
|
|
136
|
+
is still a published sample; it does not constitute testing against a client's
|
|
137
|
+
original production files. An additional CardDemo binary/oracle corpus may be
|
|
138
|
+
added when both its original bytes and independent expected values can be
|
|
139
|
+
verified and bundled without guessing.
|
|
140
|
+
|
|
141
|
+
## What belongs in package-level tests
|
|
142
|
+
|
|
143
|
+
The parser packages themselves own detailed unit coverage for grammar and conversion rules.
|
|
144
|
+
|
|
145
|
+
For example:
|
|
146
|
+
|
|
147
|
+
- JSON parser tests cover LF/CRLF recognition, EOF, carried records, multi-buffer JSON, UTF-8 boundaries and parse diagnostics;
|
|
148
|
+
- JSON projection tests cover path traversal and precise type/path reasons;
|
|
149
|
+
- CSV walker tests cover quoting, embedded newlines, malformed syntax, EOF and arbitrary physical-buffer boundaries;
|
|
150
|
+
- CSV projection tests cover compiled header indexes, field decoding and scalar conversion;
|
|
151
|
+
- `cursor-record` tests cover carry, pools, offsets and physical lifetimes;
|
|
152
|
+
- `cursor-file` tests cover result pooling and row-error policies.
|
|
153
|
+
|
|
154
|
+
This package focuses on the contracts between those modules rather than duplicating every local rule.
|
|
155
|
+
|
|
156
|
+
## Why this package exists
|
|
157
|
+
|
|
158
|
+
The integration suites are intended to catch cross-package mistakes such as:
|
|
159
|
+
|
|
160
|
+
- stale parser/projection signatures;
|
|
161
|
+
- incorrect source setup ordering;
|
|
162
|
+
- preparation-context loss;
|
|
163
|
+
- physical record numbering;
|
|
164
|
+
- carried-buffer mistakes;
|
|
165
|
+
- projection rebinding/lifetime errors;
|
|
166
|
+
- wrong row-error policy behaviour;
|
|
167
|
+
- setup failures accidentally being treated as recoverable rows;
|
|
168
|
+
- diagnostics referring to the wrong physical record.
|
|
169
|
+
|
|
170
|
+
## Type checking and Jest
|
|
171
|
+
|
|
172
|
+
Jest exercises runtime behaviour, but it is not sufficient to validate evolving TypeScript contracts.
|
|
173
|
+
|
|
174
|
+
CI/CD should compile the package separately with `tsc` as well as running Jest. This catches stale call signatures even when the test transpilation path would otherwise execute them as JavaScript.
|
|
175
|
+
|
|
176
|
+
The current package `test` script itself runs Jest only; TypeScript compilation is therefore a separate build/CI responsibility rather than something performed by that npm script.
|
|
177
|
+
|
|
178
|
+
## Current cross-package validation boundary
|
|
179
|
+
|
|
180
|
+
COBOL also has an end-to-end FB/150 integration suite here using an independently published AWS data/copybook/CSV oracle. Detailed nested ODO geometry, local codec unit tests, pooling and indexed-error tests remain in `cursor-loader-cobol`, `codec` and `layout`; this external FB suite does not establish full compiler/dialect support or variable-record framing. Run the package Jest suites, TypeScript checks and the complete repository suite separately before release. Do not publish a fixed test count in this README; the suite evolves.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './src/cursor.loader.fixture';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./src/cursor.loader.fixture"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,72 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cobol-ts/cursor-loader-test",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"description": "tests the cursor loader package",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"main": "dist/index",
|
|
6
|
+
"types": "dist/index",
|
|
7
|
+
"browserslist": {
|
|
8
|
+
"development": [
|
|
9
|
+
"last 1 chrome version",
|
|
10
|
+
"last 1 firefox version",
|
|
11
|
+
"last 1 safari version"
|
|
12
|
+
],
|
|
13
|
+
"production": [
|
|
14
|
+
">0.2%",
|
|
15
|
+
"not dead",
|
|
16
|
+
"not op_mini all"
|
|
17
|
+
]
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@cobol-ts/arrays": "0.0.1",
|
|
21
|
+
"@cobol-ts/copybook": "0.0.1",
|
|
22
|
+
"@cobol-ts/cursor-file": "0.0.1",
|
|
23
|
+
"@cobol-ts/cursor-loader-cobol": "0.0.1",
|
|
24
|
+
"@cobol-ts/cursor-loader-csv": "0.0.1",
|
|
25
|
+
"@cobol-ts/cursor-loader-json": "0.0.1",
|
|
26
|
+
"@cobol-ts/cursor-loader-types": "0.0.1",
|
|
27
|
+
"@cobol-ts/cursor-projection": "0.0.1",
|
|
28
|
+
"@cobol-ts/cursor-record": "0.0.1",
|
|
29
|
+
"@cobol-ts/errors": "0.0.1",
|
|
30
|
+
"@cobol-ts/layout": "0.0.1"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@testing-library/jest-dom": "^6.1.4",
|
|
34
|
+
"@types/jest": "^29.0.0",
|
|
35
|
+
"@types/node": "^14.0.0",
|
|
36
|
+
"jest": "^29.0.0",
|
|
37
|
+
"ts-jest": "^29.0.0",
|
|
38
|
+
"typescript": "^5.2.2"
|
|
39
|
+
},
|
|
40
|
+
"eslintConfig": {
|
|
41
|
+
"extends": [
|
|
42
|
+
"react-app",
|
|
43
|
+
"react-app/jest"
|
|
44
|
+
],
|
|
45
|
+
"overrides": [
|
|
46
|
+
{
|
|
47
|
+
"files": [
|
|
48
|
+
"**/*.stories.*"
|
|
49
|
+
],
|
|
50
|
+
"rules": {
|
|
51
|
+
"import/no-anonymous-default-export": "off"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
},
|
|
56
|
+
"files": [
|
|
57
|
+
"dist/index.js",
|
|
58
|
+
"dist/index.d.ts",
|
|
59
|
+
"dist/src/",
|
|
60
|
+
"build/"
|
|
61
|
+
],
|
|
62
|
+
"keywords": [
|
|
63
|
+
"indexing"
|
|
64
|
+
],
|
|
65
|
+
"license": "MIT",
|
|
66
|
+
"repository": "git@github.com:intellimaintain/intellimaintain.git",
|
|
67
|
+
"scripts": {
|
|
68
|
+
"test": "jest --config jest.config.json --env node",
|
|
69
|
+
"test:watch": "npm run test -- --watch",
|
|
70
|
+
"start": "react-scripts start"
|
|
71
|
+
}
|
|
6
72
|
}
|