@voxgig/sdkgen 4.39.1 → 4.40.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/bin/voxgig-sdkgen +1 -1
- package/dist/helpers/testPolicy.d.ts +8 -2
- package/dist/helpers/testPolicy.js +18 -0
- package/dist/helpers/testPolicy.js.map +1 -1
- package/dist/sdkgen.d.ts +4 -4
- package/dist/sdkgen.js +4 -3
- package/dist/sdkgen.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/project/.sdk/model/target/rust.aontu +1 -0
- package/project/.sdk/src/cmp/c/fragment/Main.fragment.c +15 -0
- package/project/.sdk/src/cmp/cpp/TestDirect_cpp.ts +2 -0
- package/project/.sdk/src/cmp/csharp/TestDirect_csharp.ts +20 -3
- package/project/.sdk/src/cmp/csharp/TestEntity_csharp.ts +43 -15
- package/project/.sdk/src/cmp/csharp/fragment/Main.fragment.cs +17 -0
- package/project/.sdk/src/cmp/elixir/fragment/Main.fragment.ex +10 -0
- package/project/.sdk/src/cmp/go/TestDirect_go.ts +23 -4
- package/project/.sdk/src/cmp/go/TestEntity_go.ts +37 -12
- package/project/.sdk/src/cmp/go/fragment/Main.fragment.go +14 -0
- package/project/.sdk/src/cmp/java/TestDirect_java.ts +18 -3
- package/project/.sdk/src/cmp/java/TestEntity_java.ts +39 -14
- package/project/.sdk/src/cmp/js/TestDirect_js.ts +7 -1
- package/project/.sdk/src/cmp/js/fragment/Main.fragment.js +7 -0
- package/project/.sdk/src/cmp/kotlin/TestDirect_kotlin.ts +18 -3
- package/project/.sdk/src/cmp/kotlin/TestEntity_kotlin.ts +37 -14
- package/project/.sdk/src/cmp/lua/TestDirect_lua.ts +13 -3
- package/project/.sdk/src/cmp/lua/TestEntity_lua.ts +36 -10
- package/project/.sdk/src/cmp/lua/fragment/Main.fragment.lua +14 -0
- package/project/.sdk/src/cmp/ocaml/TestDirect_ocaml.ts +3 -1
- package/project/.sdk/src/cmp/perl/TestDirect_perl.ts +9 -3
- package/project/.sdk/src/cmp/perl/TestEntity_perl.ts +22 -8
- package/project/.sdk/src/cmp/perl/fragment/Main.fragment.pm +6 -0
- package/project/.sdk/src/cmp/php/TestDirect_php.ts +13 -3
- package/project/.sdk/src/cmp/php/TestEntity_php.ts +31 -9
- package/project/.sdk/src/cmp/php/fragment/Main.fragment.php +14 -0
- package/project/.sdk/src/cmp/py/TestDirect_py.ts +11 -3
- package/project/.sdk/src/cmp/py/TestEntity_py.ts +30 -9
- package/project/.sdk/src/cmp/py/fragment/Main.fragment.py +6 -0
- package/project/.sdk/src/cmp/rb/TestDirect_rb.ts +9 -3
- package/project/.sdk/src/cmp/rb/TestEntity_rb.ts +25 -10
- package/project/.sdk/src/cmp/rb/fragment/Main.fragment.rb +7 -0
- package/project/.sdk/src/cmp/rust/TestDirect_rust.ts +13 -3
- package/project/.sdk/src/cmp/rust/TestEntity_rust.ts +48 -27
- package/project/.sdk/src/cmp/rust/fragment/Main.fragment.rs +15 -0
- package/project/.sdk/src/cmp/swift/fragment/Main.fragment.swift +7 -0
- package/project/.sdk/src/cmp/ts/TestDirect_ts.ts +7 -1
- package/project/.sdk/src/cmp/ts/TestEntity_ts.ts +8 -2
- package/project/.sdk/src/cmp/ts/fragment/Main.fragment.ts +7 -0
- package/project/.sdk/src/cmp/zig/TestDirect_zig.ts +1 -0
- package/project/.sdk/src/cmp/zig/fragment/Main.fragment.zig +16 -0
- package/project/.sdk/tm/c/utility/http.c +256 -0
- package/project/.sdk/tm/clojure/src/sdk/client.clj +7 -0
- package/project/.sdk/tm/clojure/src/sdk/core.clj +24 -1
- package/project/.sdk/tm/cpp/core/types.hpp +14 -0
- package/project/.sdk/tm/csharp/test/Runner.cs +49 -3
- package/project/.sdk/tm/csharp/utility/Fetcher.cs +5 -1
- package/project/.sdk/tm/elixir/lib/projectname/utility.ex +54 -19
- package/project/.sdk/tm/go/test/testsupport_test.go +44 -3
- package/project/.sdk/tm/go/utility/fetcher.go +40 -0
- package/project/.sdk/tm/java/core/SdkClient.java +7 -0
- package/project/.sdk/tm/java/test/RunnerSupport.java +45 -2
- package/project/.sdk/tm/java/utility/Fetcher.java +67 -1
- package/project/.sdk/tm/js/src/utility/MakeResultUtility.js +3 -1
- package/project/.sdk/tm/js/test/live-entity.js +7 -3
- package/project/.sdk/tm/kotlin/core/SdkClient.kt +7 -0
- package/project/.sdk/tm/kotlin/test/RunnerSupport.kt +40 -3
- package/project/.sdk/tm/kotlin/utility/Fetcher.kt +52 -1
- package/project/.sdk/tm/lua/test/runner.lua +49 -2
- package/project/.sdk/tm/lua/utility/fetcher.lua +228 -0
- package/project/.sdk/tm/ocaml/sdk_features.ml +8 -0
- package/project/.sdk/tm/perl/t/runner.pm +18 -3
- package/project/.sdk/tm/perl/utility/fetcher.pm +42 -3
- package/project/.sdk/tm/php/test/Runner.php +43 -5
- package/project/.sdk/tm/php/utility/Fetcher.php +36 -0
- package/project/.sdk/tm/php/utility/MakeResult.php +3 -1
- package/project/.sdk/tm/py/test/runner.py +32 -3
- package/project/.sdk/tm/rb/test/runner.rb +24 -1
- package/project/.sdk/tm/rust/tests/common/mod.rs +53 -5
- package/project/.sdk/tm/rust/utility/fetcher.rs +43 -3
- package/project/.sdk/tm/scala/core/SdkClient.scala +7 -0
- package/project/.sdk/tm/scala/utility/Fetcher.scala +48 -1
- package/project/.sdk/tm/ts/src/utility/MakeResultUtility.ts +3 -1
- package/project/.sdk/tm/ts/test/live-entity.ts +8 -3
- package/project/sdkgen-package.json +1 -1
- package/src/helpers/testPolicy.ts +23 -2
- package/src/sdkgen.ts +4 -2
|
@@ -216,7 +216,10 @@ ${liveStrictNote(liveStrict(model, target.name), '//', ' ')}
|
|
|
216
216
|
reason == null,
|
|
217
217
|
if (reason == null || "" == reason) "skipped via sdk-test-control.json" else reason,
|
|
218
218
|
)
|
|
219
|
-
${listSkipBlock}
|
|
219
|
+
${listSkipBlock} if (setup.live) {
|
|
220
|
+
RunnerSupport.livePace()
|
|
221
|
+
}
|
|
222
|
+
val client = setup.client
|
|
220
223
|
|
|
221
224
|
`)
|
|
222
225
|
|
|
@@ -329,7 +332,10 @@ ${listLiveQueryLines ? ' if (setup.live) {\n' + listLiveQueryLines + ' }\n
|
|
|
329
332
|
reason == null,
|
|
330
333
|
if (reason == null || "" == reason) "skipped via sdk-test-control.json" else reason,
|
|
331
334
|
)
|
|
332
|
-
${loadSkipBlock}
|
|
335
|
+
${loadSkipBlock} if (setup.live) {
|
|
336
|
+
RunnerSupport.livePace()
|
|
337
|
+
}
|
|
338
|
+
val client = setup.client
|
|
333
339
|
|
|
334
340
|
`)
|
|
335
341
|
|
|
@@ -359,10 +365,19 @@ ${loadSkipBlock} val client = setup.client
|
|
|
359
365
|
`)
|
|
360
366
|
}
|
|
361
367
|
|
|
368
|
+
// The list sends the query its route requires, as direct-list does.
|
|
369
|
+
const listQueryLines = liveQueryExamples(listPoint)
|
|
370
|
+
.map(([name, ex]) => ` listQuery[${kotlinLiteral(name)}] = ${kotlinLiteral(ex)}\n`).join('')
|
|
371
|
+
if ('' !== listQueryLines) {
|
|
372
|
+
Content(` val listQuery = linkedMapOf<String, Any?>()
|
|
373
|
+
` + listQueryLines)
|
|
374
|
+
}
|
|
375
|
+
|
|
362
376
|
Content(` val listResult = client.direct(jm(
|
|
363
377
|
"path", "${listPath}",
|
|
364
378
|
"method", "GET",
|
|
365
|
-
"params", listParams
|
|
379
|
+
"params", listParams${'' === listQueryLines ? '' : `,
|
|
380
|
+
"query", listQuery`}))
|
|
366
381
|
if (!liveOk(listResult)) {
|
|
367
382
|
RunnerSupport.liveMiss(LIVE_STRICT, "Live list discovery failed: " + RunnerSupport.liveDescribe(listResult))
|
|
368
383
|
}
|
|
@@ -18,11 +18,11 @@ import {
|
|
|
18
18
|
each,
|
|
19
19
|
buildIdNames,
|
|
20
20
|
getMatchEntries,
|
|
21
|
-
isAuthActive, envName, envToken, entityRecordIdField,
|
|
21
|
+
isAuthActive, envName, envToken, entityDataIdField, entityRecordIdField,
|
|
22
22
|
liveFlowNeeds, liveStrict, liveStrictNote,
|
|
23
23
|
liveGates, liveExcludedLines, liveExcludedSummary, LIVE_GETONLY_ENV,
|
|
24
24
|
liveRouteExamples, liveStepExamples,
|
|
25
|
-
liveEntity,
|
|
25
|
+
liveEntity, liveIdentity,
|
|
26
26
|
} from '@voxgig/sdkgen'
|
|
27
27
|
|
|
28
28
|
|
|
@@ -50,7 +50,7 @@ type OpGen = (ctx: GenCtx, step: ModelEntityFlowStep, index: number) => void
|
|
|
50
50
|
// The live prologue of a flow built from offline fixtures: blocked without
|
|
51
51
|
// the ids it binds, a create-less load reading the first listed record, and
|
|
52
52
|
// a lenient run observing its checks rather than failing on them.
|
|
53
|
-
function liveFlowGate(entity: any, needs: any, entidEnv: string, accessor: string,
|
|
53
|
+
function liveFlowGate(entity: any, needs: any, identity: any, entidEnv: string, accessor: string,
|
|
54
54
|
strict: boolean, hasSteps: boolean): string {
|
|
55
55
|
let out = ''
|
|
56
56
|
for (const [k, ex] of needs.examples || []) {
|
|
@@ -80,9 +80,11 @@ function liveFlowGate(entity: any, needs: any, entidEnv: string, accessor: strin
|
|
|
80
80
|
}
|
|
81
81
|
out += ' val client = setup.client\n'
|
|
82
82
|
if (null != needs.record) {
|
|
83
|
+
const id = `setup.idmap?.get(${JSON.stringify(needs.record)})`
|
|
83
84
|
out += ` if (setup.live) {
|
|
84
|
-
RunnerSupport.liveExisting(setup.data!!, LIVE_STRICT, ${JSON.stringify(entity.name)}
|
|
85
|
-
|
|
85
|
+
RunnerSupport.liveExisting(setup.data!!, LIVE_STRICT, ${JSON.stringify(entity.name)},
|
|
86
|
+
${JSON.stringify(identity.field)}, ${id}) {
|
|
87
|
+
listOf(linkedMapOf<String, Any?>("id" to ${id}))
|
|
86
88
|
}
|
|
87
89
|
}
|
|
88
90
|
`
|
|
@@ -92,8 +94,12 @@ function liveFlowGate(entity: any, needs: any, entidEnv: string, accessor: strin
|
|
|
92
94
|
.map(([k, v]: any) => `${JSON.stringify(k)} to setup.idmap?.get(${JSON.stringify(v)})`)
|
|
93
95
|
.concat(liveRouteExamples(entity, 'list', Object.keys(needs.discover))
|
|
94
96
|
.map(([k, ex]) => `${JSON.stringify(k)} to ${kotlinLit(ex)}`)).join(', ')
|
|
97
|
+
const given = `if (setup.syntheticOnly) null else setup.idmap?.get(${JSON.stringify(identity.key)})`
|
|
95
98
|
out += ` if (setup.live) {
|
|
96
|
-
|
|
99
|
+
val liveId: Any? = ${undefined === identity.ex ? given : `(${given}) ?: ${kotlinIdLit(identity.ex)}`}
|
|
100
|
+
RunnerSupport.livePace()
|
|
101
|
+
RunnerSupport.liveExisting(setup.data!!, LIVE_STRICT, ${JSON.stringify(entity.name)},
|
|
102
|
+
${JSON.stringify(identity.field)}, liveId) {
|
|
97
103
|
client.${accessor}(null).list(linkedMapOf<String, Any?>(${match}), null)
|
|
98
104
|
}
|
|
99
105
|
}
|
|
@@ -199,8 +205,8 @@ ${liveStrictNote(strict, '//', ' ')}
|
|
|
199
205
|
|
|
200
206
|
const flowBody = (flow: any) => {
|
|
201
207
|
const steps = flowSteps(flow) as any[]
|
|
202
|
-
Content(liveFlowGate(entity, liveFlowNeeds(entity, flow),
|
|
203
|
-
steps.length > 0))
|
|
208
|
+
Content(liveFlowGate(entity, liveFlowNeeds(entity, flow), liveIdentity(entity, flow), entidEnvVar,
|
|
209
|
+
accessor, strict, steps.length > 0))
|
|
204
210
|
|
|
205
211
|
const flowHasCreate = steps.some((s: any) => s.o === 'create')
|
|
206
212
|
if (!flowHasCreate) {
|
|
@@ -218,6 +224,7 @@ ${liveStrictNote(strict, '//', ' ')}
|
|
|
218
224
|
each(steps, (step: any, index: any) => {
|
|
219
225
|
const opgen: OpGen = GENERATE_OP[step.o]
|
|
220
226
|
if (opgen) {
|
|
227
|
+
Content(LIVE_PACE)
|
|
221
228
|
opgen({ ...genCtx, flow }, step, index)
|
|
222
229
|
Content('\n')
|
|
223
230
|
}
|
|
@@ -558,9 +565,8 @@ const generateUpdate: OpGen = (ctx, step, index) => {
|
|
|
558
565
|
assertNotNull(${resdatavar}, "expected update result to be a map")
|
|
559
566
|
`)
|
|
560
567
|
if (hasEntIdU) {
|
|
561
|
-
Content(
|
|
562
|
-
|
|
563
|
-
`)
|
|
568
|
+
Content(sameId(entity, `${resdatavar}[${rid(entity)}]`, `${datavar}Up["id"]`,
|
|
569
|
+
'expected update result id to match'))
|
|
564
570
|
}
|
|
565
571
|
|
|
566
572
|
if (step.s) {
|
|
@@ -621,9 +627,8 @@ const generateLoad: OpGen = (ctx, step, index) => {
|
|
|
621
627
|
${loadMatch(entity, step, matchvar, srcdatavar)}${liveFill(entity, step, matchvar, flow)} val ${datavar}Loaded = ${entvar}.load(${matchvar}, null)
|
|
622
628
|
val ${datavar}LoadResult = Helpers.toMapAny(if (${datavar}Loaded is SdkEntity) ${datavar}Loaded.data() else ${datavar}Loaded) ?: linkedMapOf()
|
|
623
629
|
assertNotNull(${datavar}LoadResult, "expected load result to be a map")
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
`)
|
|
630
|
+
${sameId(entity, `${datavar}LoadResult[${rid(entity)}]`, `${srcdatavar}[${rid(entity)}]`,
|
|
631
|
+
'expected load result id to match')}`)
|
|
627
632
|
} else {
|
|
628
633
|
Content(`${loadMatch(entity, step, matchvar, srcdatavar)}${liveFill(entity, step, matchvar, flow)} val ${datavar}Loaded = ${entvar}.load(${matchvar}, null)
|
|
629
634
|
assertNotNull(${datavar}Loaded, "expected load result to be non-null")
|
|
@@ -662,6 +667,24 @@ function rid(entity: any): string {
|
|
|
662
667
|
}
|
|
663
668
|
|
|
664
669
|
|
|
670
|
+
const LIVE_PACE = ` if (setup.live) {
|
|
671
|
+
RunnerSupport.livePace()
|
|
672
|
+
}
|
|
673
|
+
`
|
|
674
|
+
|
|
675
|
+
|
|
676
|
+
// A result's identity matches the one asked for, live only where the
|
|
677
|
+
// record's schema has a field to repeat it in.
|
|
678
|
+
function sameId(entity: any, result: string, expected: string, message: string): string {
|
|
679
|
+
const check = `assertTrue(RunnerSupport.liveSameId(${result}, ${expected}), ${JSON.stringify(message)})`
|
|
680
|
+
return null == entityDataIdField(entity) ? ` if (!setup.live) {
|
|
681
|
+
${check}
|
|
682
|
+
}
|
|
683
|
+
` : ` ${check}
|
|
684
|
+
`
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
|
|
665
688
|
// The fixture keeps each record's key in `id`; an entity keeping its identity
|
|
666
689
|
// in another field reads the key from there too.
|
|
667
690
|
function fixtureIdentity(entity: any): string {
|
|
@@ -223,7 +223,10 @@ describe("${entity.Name}Direct", function()
|
|
|
223
223
|
pending(_reason or "skipped via sdk-test-control.json")
|
|
224
224
|
return
|
|
225
225
|
end
|
|
226
|
-
${getOnlyKeysBlock(model, entity, 'direct-list-' + entity.name, listParams.map(liveKey))}${liveKeysBlock(listParams.map(liveKey), entidEnvVar)}
|
|
226
|
+
${getOnlyKeysBlock(model, entity, 'direct-list-' + entity.name, listParams.map(liveKey))}${liveKeysBlock(listParams.map(liveKey), entidEnvVar)} if setup.live then
|
|
227
|
+
runner.live_pace()
|
|
228
|
+
end
|
|
229
|
+
local client = setup.client
|
|
227
230
|
|
|
228
231
|
local params = {}
|
|
229
232
|
local query = {}
|
|
@@ -286,7 +289,10 @@ ${listLiveQueryLines ? ' if setup.live then\n' + listLiveQueryLines + ' en
|
|
|
286
289
|
pending(_reason or "skipped via sdk-test-control.json")
|
|
287
290
|
return
|
|
288
291
|
end
|
|
289
|
-
${getOnlyKeysBlock(model, entity, 'direct-load-' + entity.name, [...new Set(loadLiveIdKeys)])}${liveKeysBlock([...new Set(loadLiveIdKeys)], entidEnvVar)}
|
|
292
|
+
${getOnlyKeysBlock(model, entity, 'direct-load-' + entity.name, [...new Set(loadLiveIdKeys)])}${liveKeysBlock([...new Set(loadLiveIdKeys)], entidEnvVar)} if setup.live then
|
|
293
|
+
runner.live_pace()
|
|
294
|
+
end
|
|
295
|
+
local client = setup.client
|
|
290
296
|
|
|
291
297
|
local params = {}
|
|
292
298
|
local query = {}
|
|
@@ -296,10 +302,14 @@ ${loadLiveQueryLines ? loadLiveQueryLines + '\n' : ''}`)
|
|
|
296
302
|
Content(loadExampleLines + '\n')
|
|
297
303
|
}
|
|
298
304
|
else if (discover) {
|
|
305
|
+
// The list sends the query its route requires, as direct-list does.
|
|
306
|
+
const listQuery = liveQueryExamples(listPoint)
|
|
307
|
+
.map(([name, ex]) => `[${formatLuaValue(name)}] = ${formatLuaValue(ex)}`).join(', ')
|
|
299
308
|
Content(` local list_result, list_err = client:direct({
|
|
300
309
|
path = "${listPath}",
|
|
301
310
|
method = "GET",
|
|
302
|
-
params = {${listParams.map((p: any) => `["${p.n}"] = setup.idmap["${liveKey(p)}"]`).join(', ')}}
|
|
311
|
+
params = {${listParams.map((p: any) => `["${p.n}"] = setup.idmap["${liveKey(p)}"]`).join(', ')}},${'' === listQuery ? '' : `
|
|
312
|
+
query = {${listQuery}},`}
|
|
303
313
|
})
|
|
304
314
|
if not live_ok(list_result, list_err) then
|
|
305
315
|
runner.live_miss(pending, LIVE_STRICT, "Live list discovery failed: " .. runner.live_describe(list_result, list_err))
|
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
liveFlowNeeds, liveStrict, liveStrictNote,
|
|
33
33
|
liveRouteExamples, liveStepExamples, flowLoadRoute, flowLoadReadsRecord,
|
|
34
34
|
liveGates, liveExcludedLines, liveExcludedSummary, LIVE_GETONLY_ENV,
|
|
35
|
-
liveEntity,
|
|
35
|
+
liveEntity, liveIdentity,
|
|
36
36
|
} from '@voxgig/sdkgen'
|
|
37
37
|
|
|
38
38
|
import { formatLuaValue } from './utility_lua'
|
|
@@ -52,7 +52,7 @@ type OpGen = (ctx: GenCtx, step: ModelEntityFlowStep, index: number) => void
|
|
|
52
52
|
// The live prologue of a flow built from offline fixtures: blocked without
|
|
53
53
|
// the ids it binds, a create-less load reading the first listed record, and
|
|
54
54
|
// a lenient run observing its checks rather than failing on them.
|
|
55
|
-
function liveFlowGate(entity: any, needs: any, entidEnv: string, strict: boolean): string {
|
|
55
|
+
function liveFlowGate(entity: any, needs: any, identity: any, entidEnv: string, strict: boolean): string {
|
|
56
56
|
let out = ''
|
|
57
57
|
if (null != needs.examples) {
|
|
58
58
|
out += ` if setup.live then
|
|
@@ -83,10 +83,11 @@ function liveFlowGate(entity: any, needs: any, entidEnv: string, strict: boolean
|
|
|
83
83
|
}
|
|
84
84
|
out += ' local client = setup.client\n'
|
|
85
85
|
if (null != needs.record) {
|
|
86
|
+
const id = `setup.idmap[${JSON.stringify(needs.record)}]`
|
|
86
87
|
out += ` if setup.live then
|
|
87
88
|
runner.live_existing(pending, setup, LIVE_STRICT, ${JSON.stringify(entity.name)}, function()
|
|
88
|
-
return { { id =
|
|
89
|
-
end)
|
|
89
|
+
return { { id = ${id} } }
|
|
90
|
+
end, ${JSON.stringify(identity.field)}, ${id})
|
|
90
91
|
end
|
|
91
92
|
`
|
|
92
93
|
}
|
|
@@ -96,9 +97,17 @@ function liveFlowGate(entity: any, needs: any, entidEnv: string, strict: boolean
|
|
|
96
97
|
.concat(liveRouteExamples(entity, 'list', Object.keys(needs.discover))
|
|
97
98
|
.map(([k, ex]) => `[${JSON.stringify(k)}] = ${formatLuaValue(ex)}`)).join(', ')
|
|
98
99
|
out += ` if setup.live then
|
|
100
|
+
local _live_id = nil
|
|
101
|
+
if not setup.synthetic_only then
|
|
102
|
+
_live_id = setup.idmap[${JSON.stringify(identity.key)}]
|
|
103
|
+
end
|
|
104
|
+
${undefined === identity.ex ? '' : ` if _live_id == nil then
|
|
105
|
+
_live_id = ${formatLuaValue(identity.ex)}
|
|
106
|
+
end
|
|
107
|
+
`} runner.live_pace()
|
|
99
108
|
runner.live_existing(pending, setup, LIVE_STRICT, ${JSON.stringify(entity.name)}, function()
|
|
100
109
|
return client:${entity.Name}(nil):list({${match}}, nil)
|
|
101
|
-
end)
|
|
110
|
+
end, ${JSON.stringify(identity.field)}, _live_id)
|
|
102
111
|
end
|
|
103
112
|
`
|
|
104
113
|
}
|
|
@@ -245,7 +254,7 @@ ${failureTests(entity)}` : ''}${validateTest(entity)}
|
|
|
245
254
|
|
|
246
255
|
const flowBody = (flow: any) => {
|
|
247
256
|
const steps = flowSteps(flow) as any[]
|
|
248
|
-
Content(liveFlowGate(entity, liveFlowNeeds(entity, flow), entidEnv, strict) + '\n')
|
|
257
|
+
Content(liveFlowGate(entity, liveFlowNeeds(entity, flow), liveIdentity(entity, flow), entidEnv, strict) + '\n')
|
|
249
258
|
|
|
250
259
|
// Check if the flow has a create step
|
|
251
260
|
const flowHasCreate = steps.some((s: any) => s.o === 'create')
|
|
@@ -273,6 +282,7 @@ ${failureTests(entity)}` : ''}${validateTest(entity)}
|
|
|
273
282
|
}
|
|
274
283
|
const opgen: OpGen = GENERATE_OP[step.o]
|
|
275
284
|
if (opgen) {
|
|
285
|
+
Content(LIVE_PACE)
|
|
276
286
|
opgen({ ...genCtx, flow }, step, index)
|
|
277
287
|
Content('\n')
|
|
278
288
|
}
|
|
@@ -588,8 +598,7 @@ const generateUpdate: OpGen = (ctx, step, index) => {
|
|
|
588
598
|
assert.is_not_nil(${resdatavar})
|
|
589
599
|
`)
|
|
590
600
|
if (hasEntIdU) {
|
|
591
|
-
Content(
|
|
592
|
-
`)
|
|
601
|
+
Content(sameId(entity, `${resdatavar}[${rid(entity)}]`, `${datavar}_up["id"]`))
|
|
593
602
|
}
|
|
594
603
|
|
|
595
604
|
if (step.s) {
|
|
@@ -652,8 +661,7 @@ ${loadMatch(entity, step, matchvar, srcdatavar)}${liveFill(entity, step, matchva
|
|
|
652
661
|
assert.is_nil(err)
|
|
653
662
|
local ${datavar}_load_result = helpers.to_map(type(${datavar}_loaded) == 'table' and ${datavar}_loaded.data_get and ${datavar}_loaded:data_get() or ${datavar}_loaded)
|
|
654
663
|
assert.is_not_nil(${datavar}_load_result)
|
|
655
|
-
|
|
656
|
-
`)
|
|
664
|
+
${sameId(entity, `${datavar}_load_result[${rid(entity)}]`, `${srcdatavar}[${rid(entity)}]`)}`)
|
|
657
665
|
}
|
|
658
666
|
else {
|
|
659
667
|
Content(` local ${matchvar} = {}
|
|
@@ -702,6 +710,24 @@ function rid(entity: any): string {
|
|
|
702
710
|
}
|
|
703
711
|
|
|
704
712
|
|
|
713
|
+
const LIVE_PACE = ` if setup.live then
|
|
714
|
+
runner.live_pace()
|
|
715
|
+
end
|
|
716
|
+
`
|
|
717
|
+
|
|
718
|
+
|
|
719
|
+
// A result's identity matches the one asked for, live only where the
|
|
720
|
+
// record's schema has a field to repeat it in.
|
|
721
|
+
function sameId(entity: any, result: string, expected: string): string {
|
|
722
|
+
const check = `assert.is_true(runner.live_same_id(${result}, ${expected}))`
|
|
723
|
+
return null == entityDataIdField(entity) ? ` if not setup.live then
|
|
724
|
+
${check}
|
|
725
|
+
end
|
|
726
|
+
` : ` ${check}
|
|
727
|
+
`
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
|
|
705
731
|
// The fixture keeps each record's key in `id`; an entity keeping its identity
|
|
706
732
|
// in another field reads the key from there too.
|
|
707
733
|
function fixtureIdentity(entity: any): string {
|
|
@@ -236,6 +236,20 @@ function ProjectNameSDK:prepare(fetchargs)
|
|
|
236
236
|
end
|
|
237
237
|
end
|
|
238
238
|
|
|
239
|
+
-- A raw request has no point to declare its response type, so it asks
|
|
240
|
+
-- for the JSON it reads: an API that negotiates on Accept otherwise
|
|
241
|
+
-- answers in its own default format. A caller's own accept wins.
|
|
242
|
+
local has_accept = false
|
|
243
|
+
for k, _ in pairs(ctx.spec.headers) do
|
|
244
|
+
if string.lower(tostring(k)) == "accept" then
|
|
245
|
+
has_accept = true
|
|
246
|
+
break
|
|
247
|
+
end
|
|
248
|
+
end
|
|
249
|
+
if not has_accept then
|
|
250
|
+
ctx.spec.headers["accept"] = "application/json"
|
|
251
|
+
end
|
|
252
|
+
|
|
239
253
|
local _, err = utility.prepare_auth(ctx)
|
|
240
254
|
if err ~= nil then
|
|
241
255
|
return nil, err
|
|
@@ -36,7 +36,9 @@ let () =
|
|
|
36
36
|
(jo [("path", Str "/${ocamlString(entity.name)}"); ("method", Str "GET")]) in
|
|
37
37
|
check_vbool "ok" (getp result "ok") true;
|
|
38
38
|
check_vstr "data.id" (getp (getp result "data") "id") "direct01";
|
|
39
|
-
check_int "one call" (List.length !calls) 1
|
|
39
|
+
check_int "one call" (List.length !calls) 1;
|
|
40
|
+
let fetchdef = (match !calls with (List r) :: _ -> List.nth !r 1 | _ -> Noval) in
|
|
41
|
+
check_vstr "accept" (getp (getp fetchdef "headers") "accept") "application/json")
|
|
40
42
|
`)
|
|
41
43
|
})
|
|
42
44
|
})
|
|
@@ -238,7 +238,8 @@ sub live_ok {
|
|
|
238
238
|
pass('${label}: skipped via sdk-test-control.json');
|
|
239
239
|
last DIRECT_LIST;
|
|
240
240
|
}
|
|
241
|
-
${getOnlyKeysBlock(model, entity, label, 'DIRECT_LIST', listParams.map(liveKey))}${liveKeysBlock(N, label, 'DIRECT_LIST', listParams.map(liveKey), entidEnvVar)}
|
|
241
|
+
${getOnlyKeysBlock(model, entity, label, 'DIRECT_LIST', listParams.map(liveKey))}${liveKeysBlock(N, label, 'DIRECT_LIST', listParams.map(liveKey), entidEnvVar)} ${N}TestRunner::live_pace() if $setup->{live};
|
|
242
|
+
my $client = $setup->{client};
|
|
242
243
|
|
|
243
244
|
my $params = {};
|
|
244
245
|
my $query = {};
|
|
@@ -303,7 +304,8 @@ ${listLiveQueryLines ? ' if ($setup->{live}) {\n' + listLiveQueryLines + ' }\n
|
|
|
303
304
|
pass('${label}: skipped via sdk-test-control.json');
|
|
304
305
|
last DIRECT_LOAD;
|
|
305
306
|
}
|
|
306
|
-
${getOnlyKeysBlock(model, entity, label, 'DIRECT_LOAD', [...new Set(loadLiveIdKeys)])}${liveKeysBlock(N, label, 'DIRECT_LOAD', [...new Set(loadLiveIdKeys)], entidEnvVar)}
|
|
307
|
+
${getOnlyKeysBlock(model, entity, label, 'DIRECT_LOAD', [...new Set(loadLiveIdKeys)])}${liveKeysBlock(N, label, 'DIRECT_LOAD', [...new Set(loadLiveIdKeys)], entidEnvVar)} ${N}TestRunner::live_pace() if $setup->{live};
|
|
308
|
+
my $client = $setup->{client};
|
|
307
309
|
|
|
308
310
|
my $params = {};
|
|
309
311
|
my $query = {};
|
|
@@ -313,10 +315,14 @@ ${loadLiveQueryLines ? loadLiveQueryLines + '\n' : ''}`)
|
|
|
313
315
|
Content(loadExampleLines + '\n')
|
|
314
316
|
}
|
|
315
317
|
else if (discover) {
|
|
318
|
+
// The list sends the query its route requires, as direct-list does.
|
|
319
|
+
const listQuery = liveQueryExamples(listPoint)
|
|
320
|
+
.map(([name, ex]) => `${perlScalar(name)} => ${perlScalar(ex)}`).join(', ')
|
|
316
321
|
Content(` my $list_result = $client->direct({
|
|
317
322
|
'path' => '${listPath}',
|
|
318
323
|
'method' => 'GET',
|
|
319
|
-
'params' => {${listParams.map((p: any) => `'${p.n}' => $setup->{idmap}{'${liveKey(p)}'}`).join(', ')}}
|
|
324
|
+
'params' => {${listParams.map((p: any) => `'${p.n}' => $setup->{idmap}{'${liveKey(p)}'}`).join(', ')}},${'' === listQuery ? '' : `
|
|
325
|
+
'query' => {${listQuery}},`}
|
|
320
326
|
});
|
|
321
327
|
if (!live_ok($list_result)) {
|
|
322
328
|
${N}TestRunner::live_miss(LIVE_STRICT, '${label}', 'Live list discovery failed: ' . ${N}TestRunner::live_describe($list_result));
|
|
@@ -18,13 +18,13 @@ import {
|
|
|
18
18
|
each,
|
|
19
19
|
buildIdNames,
|
|
20
20
|
getMatchEntries,
|
|
21
|
-
isAuthActive, envName, envToken, entityRecordIdField,
|
|
21
|
+
isAuthActive, envName, envToken, entityDataIdField, entityRecordIdField,
|
|
22
22
|
serverVarEnv,
|
|
23
23
|
serverVariables,
|
|
24
24
|
liveFlowNeeds, liveStrict, liveStrictNote,
|
|
25
25
|
liveGates, liveExcludedLines, liveExcludedSummary, LIVE_GETONLY_ENV,
|
|
26
26
|
liveRouteExamples, liveStepExamples, flowLoadRoute, flowLoadReadsRecord,
|
|
27
|
-
liveEntity,
|
|
27
|
+
liveEntity, liveIdentity,
|
|
28
28
|
} from '@voxgig/sdkgen'
|
|
29
29
|
|
|
30
30
|
import { perlStringLiteral } from './utility_perl'
|
|
@@ -47,7 +47,7 @@ type OpGen = (ctx: GenCtx, step: ModelEntityFlowStep, index: number) => void
|
|
|
47
47
|
// The live prologue of a flow built from offline fixtures: blocked without
|
|
48
48
|
// the ids it binds, a create-less load reading the first listed record, and
|
|
49
49
|
// a lenient run reporting a failed check without failing the test.
|
|
50
|
-
function liveFlowGate(N: string, entity: any, needs: any, entidEnv: string,
|
|
50
|
+
function liveFlowGate(N: string, entity: any, needs: any, identity: any, entidEnv: string,
|
|
51
51
|
strict: boolean): string {
|
|
52
52
|
const label = entity.name + ': basic flow'
|
|
53
53
|
let out = ''
|
|
@@ -79,9 +79,10 @@ function liveFlowGate(N: string, entity: any, needs: any, entidEnv: string,
|
|
|
79
79
|
}
|
|
80
80
|
out += ' my $client = $setup->{client};\n'
|
|
81
81
|
if (null != needs.record) {
|
|
82
|
+
const id = `$setup->{idmap}{${perlLit(needs.record)}}`
|
|
82
83
|
out += ` if ($setup->{live}) {
|
|
83
84
|
${N}TestRunner::live_existing($setup, LIVE_STRICT, '${label}', '${entity.name}',
|
|
84
|
-
sub { [{ 'id' => $
|
|
85
|
+
sub { [{ 'id' => ${id} }] }, ${perlLit(identity.field)}, ${id}) or last BASIC_FLOW;
|
|
85
86
|
}
|
|
86
87
|
`
|
|
87
88
|
}
|
|
@@ -91,8 +92,12 @@ function liveFlowGate(N: string, entity: any, needs: any, entidEnv: string,
|
|
|
91
92
|
.concat(liveRouteExamples(entity, 'list', Object.keys(needs.discover))
|
|
92
93
|
.map(([k, ex]) => `'${k}' => ${perlLit(ex)}`)).join(', ')
|
|
93
94
|
out += ` if ($setup->{live}) {
|
|
95
|
+
my $live_id = $setup->{synthetic_only} ? undef : $setup->{idmap}{${perlLit(identity.key)}};
|
|
96
|
+
${undefined === identity.ex ? '' : ` $live_id //= ${perlLit(identity.ex)};
|
|
97
|
+
`} ${N}TestRunner::live_pace();
|
|
94
98
|
${N}TestRunner::live_existing($setup, LIVE_STRICT, '${label}', '${entity.name}',
|
|
95
|
-
sub { $client->${entity.Name}(undef)->list({${match}}, undef) })
|
|
99
|
+
sub { $client->${entity.Name}(undef)->list({${match}}, undef) }, ${perlLit(identity.field)}, $live_id)
|
|
100
|
+
or last BASIC_FLOW;
|
|
96
101
|
}
|
|
97
102
|
`
|
|
98
103
|
}
|
|
@@ -211,7 +216,8 @@ BASIC_FLOW: {
|
|
|
211
216
|
|
|
212
217
|
const flowBody = (flow: any) => {
|
|
213
218
|
const steps = flowSteps(flow) as any[]
|
|
214
|
-
Content(liveFlowGate(N, entity, liveFlowNeeds(entity, flow), ENTIDVAR, strict) +
|
|
219
|
+
Content(liveFlowGate(N, entity, liveFlowNeeds(entity, flow), liveIdentity(entity, flow), ENTIDVAR, strict) +
|
|
220
|
+
' my %V;\n\n')
|
|
215
221
|
|
|
216
222
|
// Check if the flow has a create step
|
|
217
223
|
const flowHasCreate = steps.some((s: any) => s.o === 'create')
|
|
@@ -231,6 +237,7 @@ BASIC_FLOW: {
|
|
|
231
237
|
each(steps, (step: any, index: any) => {
|
|
232
238
|
const opgen: OpGen = GENERATE_OP[step.o]
|
|
233
239
|
if (opgen) {
|
|
240
|
+
Content(` ${N}TestRunner::live_pace() if $setup->{live};\n`)
|
|
234
241
|
opgen({ ...genCtx, flow }, step, index)
|
|
235
242
|
Content('\n')
|
|
236
243
|
}
|
|
@@ -519,7 +526,7 @@ const generateUpdate: OpGen = (ctx, step, index) => {
|
|
|
519
526
|
ok(defined $V{${resdatavar}}, '${entity.name} update: data');
|
|
520
527
|
`)
|
|
521
528
|
if (hasEntIdU) {
|
|
522
|
-
Content(` is($V{${resdatavar}}{${rid(entity)}}, $V{${datavar}_up}{id}, '${entity.name} update: id');
|
|
529
|
+
Content(` is($V{${resdatavar}}{${rid(entity)}}, $V{${datavar}_up}{id}, '${entity.name} update: id')${liveDeclared(entity)};
|
|
523
530
|
`)
|
|
524
531
|
}
|
|
525
532
|
|
|
@@ -582,7 +589,7 @@ const generateLoad: OpGen = (ctx, step, index) => {
|
|
|
582
589
|
${loadMatch(entity, step, matchvar, srcdatavar)}${liveFill(entity, step, matchvar, flow)} $V{${datavar}_loaded} = $V{${entvar}}->load($V{${matchvar}}, undef);
|
|
583
590
|
$V{${datavar}_load_result} = ${N}Helpers::to_map(ref($V{${datavar}_loaded}) && $V{${datavar}_loaded}->can('data_get') ? $V{${datavar}_loaded}->data_get : $V{${datavar}_loaded});
|
|
584
591
|
ok(defined $V{${datavar}_load_result}, '${entity.name} load: data');
|
|
585
|
-
is($V{${datavar}_load_result}{${rid(entity)}}, $V{${srcdatavar}}{${rid(entity)}}, '${entity.name} load: id');
|
|
592
|
+
is($V{${datavar}_load_result}{${rid(entity)}}, $V{${srcdatavar}}{${rid(entity)}}, '${entity.name} load: id')${liveDeclared(entity)};
|
|
586
593
|
`)
|
|
587
594
|
}
|
|
588
595
|
else {
|
|
@@ -628,6 +635,13 @@ function rid(entity: any): string {
|
|
|
628
635
|
}
|
|
629
636
|
|
|
630
637
|
|
|
638
|
+
// `is` compares string forms, so a number matches the path value naming it;
|
|
639
|
+
// a record whose schema has no field for the identity is not compared live.
|
|
640
|
+
function liveDeclared(entity: any): string {
|
|
641
|
+
return null == entityDataIdField(entity) ? ' unless $setup->{live}' : ''
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
|
|
631
645
|
// The fixture keeps each record's key in `id`; an entity keeping its identity
|
|
632
646
|
// in another field reads the key from there too.
|
|
633
647
|
function fixtureIdentity(entity: any): string {
|
|
@@ -181,6 +181,12 @@ sub prepare {
|
|
|
181
181
|
$ctx->{spec}{headers}{$_} = $uh->{$_} for keys %$uh;
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
+
# A raw request has no point to declare its response type, so it asks
|
|
185
|
+
# for the JSON it reads: an API that negotiates on Accept otherwise
|
|
186
|
+
# answers in its own default format. A caller's own accept wins.
|
|
187
|
+
$ctx->{spec}{headers}{'accept'} = 'application/json'
|
|
188
|
+
unless grep { 'accept' eq lc $_ } keys %{ $ctx->{spec}{headers} };
|
|
189
|
+
|
|
184
190
|
my (undef, $err) = $utility->{prepare_auth}->($ctx);
|
|
185
191
|
die $err if $err;
|
|
186
192
|
|
|
@@ -225,7 +225,10 @@ ${liveStrictNote(liveStrict(model, target.name), '//', ' ')}
|
|
|
225
225
|
$this->markTestSkipped($_reason ?? "skipped via sdk-test-control.json");
|
|
226
226
|
return;
|
|
227
227
|
}
|
|
228
|
-
${getOnlyKeysBlock(model, entity, 'direct-list-' + entity.name, listParams.map(liveKey))}${liveKeysBlock(listParams.map(liveKey), entidEnvVar)}
|
|
228
|
+
${getOnlyKeysBlock(model, entity, 'direct-list-' + entity.name, listParams.map(liveKey))}${liveKeysBlock(listParams.map(liveKey), entidEnvVar)} if (!empty($setup["live"])) {
|
|
229
|
+
Runner::live_pace();
|
|
230
|
+
}
|
|
231
|
+
$client = $setup["client"];
|
|
229
232
|
|
|
230
233
|
$params = [];
|
|
231
234
|
$query = [];
|
|
@@ -286,7 +289,10 @@ ${listLiveQueryLines ? ' if ($setup["live"]) {\n' + listLiveQueryLines +
|
|
|
286
289
|
$this->markTestSkipped($_reason ?? "skipped via sdk-test-control.json");
|
|
287
290
|
return;
|
|
288
291
|
}
|
|
289
|
-
${getOnlyKeysBlock(model, entity, 'direct-load-' + entity.name, [...new Set(loadLiveIdKeys)])}${liveKeysBlock([...new Set(loadLiveIdKeys)], entidEnvVar)}
|
|
292
|
+
${getOnlyKeysBlock(model, entity, 'direct-load-' + entity.name, [...new Set(loadLiveIdKeys)])}${liveKeysBlock([...new Set(loadLiveIdKeys)], entidEnvVar)} if (!empty($setup["live"])) {
|
|
293
|
+
Runner::live_pace();
|
|
294
|
+
}
|
|
295
|
+
$client = $setup["client"];
|
|
290
296
|
|
|
291
297
|
$params = [];
|
|
292
298
|
$query = [];
|
|
@@ -296,10 +302,14 @@ ${loadLiveQueryLines ? loadLiveQueryLines + '\n' : ''}`)
|
|
|
296
302
|
Content(loadExampleLines + '\n')
|
|
297
303
|
}
|
|
298
304
|
else if (discover) {
|
|
305
|
+
// The list sends the query its route requires, as direct-list does.
|
|
306
|
+
const listQuery = liveQueryExamples(listPoint)
|
|
307
|
+
.map(([name, ex]) => `${formatPhpValue(name)} => ${formatPhpValue(ex)}`).join(', ')
|
|
299
308
|
Content(` $list_result = $client->direct([
|
|
300
309
|
"path" => "${listPath}",
|
|
301
310
|
"method" => "GET",
|
|
302
|
-
"params" => [${listParams.map((p: any) => `"${p.n}" => $setup["idmap"]["${liveKey(p)}"] ?? null`).join(', ')}]
|
|
311
|
+
"params" => [${listParams.map((p: any) => `"${p.n}" => $setup["idmap"]["${liveKey(p)}"] ?? null`).join(', ')}],${'' === listQuery ? '' : `
|
|
312
|
+
"query" => [${listQuery}],`}
|
|
303
313
|
]);
|
|
304
314
|
if (!self::liveOk($list_result)) {
|
|
305
315
|
Runner::live_miss(self::LIVE_STRICT, "Live list discovery failed: " . Runner::live_describe($list_result));
|
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
liveFlowNeeds, liveStrict, liveStrictNote,
|
|
34
34
|
liveRouteExamples, liveStepExamples, flowLoadRoute, flowLoadReadsRecord,
|
|
35
35
|
liveGates, liveExcludedLines, liveExcludedSummary, LIVE_GETONLY_ENV,
|
|
36
|
-
liveEntity,
|
|
36
|
+
liveEntity, liveIdentity,
|
|
37
37
|
} from '@voxgig/sdkgen'
|
|
38
38
|
|
|
39
39
|
import { formatPhpValue } from './utility_php'
|
|
@@ -42,7 +42,7 @@ import { formatPhpValue } from './utility_php'
|
|
|
42
42
|
// The live prologue of a flow built from offline fixtures: blocked without
|
|
43
43
|
// the ids it binds, a create-less load reading the first listed record, and
|
|
44
44
|
// a lenient run observing its checks rather than failing on them.
|
|
45
|
-
function liveFlowGate(entity: any, needs: any, entidEnv: string, accessor: string,
|
|
45
|
+
function liveFlowGate(entity: any, needs: any, identity: any, entidEnv: string, accessor: string,
|
|
46
46
|
strict: boolean): string {
|
|
47
47
|
let out = ''
|
|
48
48
|
if (null != needs.examples) {
|
|
@@ -74,9 +74,10 @@ function liveFlowGate(entity: any, needs: any, entidEnv: string, accessor: strin
|
|
|
74
74
|
}
|
|
75
75
|
out += ' $client = $setup["client"];\n'
|
|
76
76
|
if (null != needs.record) {
|
|
77
|
+
const id = `$setup["idmap"][${JSON.stringify(needs.record)}] ?? null`
|
|
77
78
|
out += ` if (!empty($setup["live"])) {
|
|
78
79
|
Runner::live_existing($setup, self::LIVE_STRICT, ${JSON.stringify(entity.name)},
|
|
79
|
-
fn() => [["id" => $
|
|
80
|
+
fn() => [["id" => ${id}]], ${JSON.stringify(identity.field)}, ${id});
|
|
80
81
|
}
|
|
81
82
|
`
|
|
82
83
|
}
|
|
@@ -86,8 +87,11 @@ function liveFlowGate(entity: any, needs: any, entidEnv: string, accessor: strin
|
|
|
86
87
|
.concat(liveRouteExamples(entity, 'list', Object.keys(needs.discover))
|
|
87
88
|
.map(([k, ex]) => `${JSON.stringify(k)} => ${formatPhpValue(ex)}`)).join(', ')
|
|
88
89
|
out += ` if (!empty($setup["live"])) {
|
|
90
|
+
$_liveId = empty($setup["synthetic_only"]) ? ($setup["idmap"][${JSON.stringify(identity.key)}] ?? null) : null;
|
|
91
|
+
${undefined === identity.ex ? '' : ` $_liveId = $_liveId ?? ${formatPhpValue(identity.ex)};
|
|
92
|
+
`} Runner::live_pace();
|
|
89
93
|
Runner::live_existing($setup, self::LIVE_STRICT, ${JSON.stringify(entity.name)},
|
|
90
|
-
fn() => $client->${accessor}(null)->list([${match}], null));
|
|
94
|
+
fn() => $client->${accessor}(null)->list([${match}], null), ${JSON.stringify(identity.field)}, $_liveId);
|
|
91
95
|
}
|
|
92
96
|
`
|
|
93
97
|
}
|
|
@@ -249,7 +253,8 @@ ${failureTests(model, entity, accessor)}${validateListTest(model, entity, access
|
|
|
249
253
|
|
|
250
254
|
const flowBody = (flow: any) => {
|
|
251
255
|
const steps = flowSteps(flow) as any[]
|
|
252
|
-
Content(liveFlowGate(entity, liveFlowNeeds(entity, flow), entidEnv, accessor,
|
|
256
|
+
Content(liveFlowGate(entity, liveFlowNeeds(entity, flow), liveIdentity(entity, flow), entidEnv, accessor,
|
|
257
|
+
strict) + '\n')
|
|
253
258
|
|
|
254
259
|
// Check if the flow has a create step
|
|
255
260
|
const flowHasCreate = steps.some((s: any) => s.o === 'create')
|
|
@@ -277,6 +282,7 @@ ${failureTests(model, entity, accessor)}${validateListTest(model, entity, access
|
|
|
277
282
|
}
|
|
278
283
|
const opgen: OpGen = GENERATE_OP[step.o]
|
|
279
284
|
if (opgen) {
|
|
285
|
+
Content(LIVE_PACE)
|
|
280
286
|
opgen({ ...genCtx, flow }, step, index)
|
|
281
287
|
Content('\n')
|
|
282
288
|
}
|
|
@@ -590,8 +596,7 @@ const generateUpdate: OpGen = (ctx, step, index) => {
|
|
|
590
596
|
$this->assertNotNull($${resdatavar});
|
|
591
597
|
`)
|
|
592
598
|
if (hasEntIdU) {
|
|
593
|
-
Content(
|
|
594
|
-
`)
|
|
599
|
+
Content(sameId(entity, `$${resdatavar}[${rid(entity)}] ?? null`, `$${datavar}_up["id"]`))
|
|
595
600
|
}
|
|
596
601
|
|
|
597
602
|
if (step.s) {
|
|
@@ -653,8 +658,7 @@ const generateLoad: OpGen = (ctx, step, index) => {
|
|
|
653
658
|
${loadMatch(entity, step, matchvar, srcdatavar)}${liveFill(entity, step, matchvar, flow)} $${datavar}_loaded = $${entvar}->load($${matchvar}, null);
|
|
654
659
|
$${datavar}_load_result = Helpers::to_map(is_object($${datavar}_loaded) && method_exists($${datavar}_loaded, 'data_get') ? $${datavar}_loaded->data_get() : $${datavar}_loaded);
|
|
655
660
|
$this->assertNotNull($${datavar}_load_result);
|
|
656
|
-
|
|
657
|
-
`)
|
|
661
|
+
${sameId(entity, `$${datavar}_load_result[${rid(entity)}] ?? null`, `$${srcdatavar}[${rid(entity)}]`)}`)
|
|
658
662
|
}
|
|
659
663
|
else {
|
|
660
664
|
Content(` $${matchvar} = [];
|
|
@@ -701,6 +705,24 @@ function rid(entity: any): string {
|
|
|
701
705
|
}
|
|
702
706
|
|
|
703
707
|
|
|
708
|
+
const LIVE_PACE = ` if (!empty($setup["live"])) {
|
|
709
|
+
Runner::live_pace();
|
|
710
|
+
}
|
|
711
|
+
`
|
|
712
|
+
|
|
713
|
+
|
|
714
|
+
// A result's identity matches the one asked for, live only where the
|
|
715
|
+
// record's schema has a field to repeat it in.
|
|
716
|
+
function sameId(entity: any, result: string, expected: string): string {
|
|
717
|
+
const check = `$this->assertTrue(Runner::live_same_id(${result}, ${expected}));`
|
|
718
|
+
return null == entityDataIdField(entity) ? ` if (empty($setup["live"])) {
|
|
719
|
+
${check}
|
|
720
|
+
}
|
|
721
|
+
` : ` ${check}
|
|
722
|
+
`
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
|
|
704
726
|
// The fixture keeps each record's key in `id`; an entity keeping its identity
|
|
705
727
|
// in another field reads the key from there too.
|
|
706
728
|
function fixtureIdentity(entity: any): string {
|