fix(ui): не подменять неполные сетевые счётчики нулями
This commit is contained in:
1 parent
587dd94f82
commit
1deccf862c
13 files changed
+84
-99
No files matched your search
@@ -0,0 +1,14 @@
|
||||
import assert from "node:assert/strict"
|
||||
import {test} from "node:test"
|
||||
import {boundedCompleteCount,completeCollectionCount,completeContainerCount} from "./complete-count.js"
|
||||
test("complete counts distinguish known zero, partial and missing failure metadata",()=>{
|
||||
assert.equal(completeCollectionCount({rows:[],failures:[]},"rows"),0)
|
||||
for(const raw of [{rows:[]},{rows:[],failures:[{}]},{rows:null,failures:[]}])assert.equal(completeCollectionCount(raw,"rows"),undefined)
|
||||
assert.equal(completeContainerCount({servers:[]}),0);assert.equal(completeContainerCount({servers:[{availability:"available",containers:[{}],failures:[{resource:"envs"}]}]}),1)
|
||||
for(const availability of ["unsupported","error"])assert.equal(completeContainerCount({servers:[{availability,containers:[],failures:[]}]}),undefined)
|
||||
})
|
||||
test("bounded reader omits thrown, malformed and timed out counts without publishing late success",async()=>{
|
||||
assert.equal(await boundedCompleteCount(async()=>0,x=>x),0);assert.equal(await boundedCompleteCount(async()=>{throw Error("offline")},x=>x),undefined)
|
||||
for(const value of [-1,NaN,Infinity,1.5])assert.equal(await boundedCompleteCount(async()=>value,x=>x),undefined)
|
||||
let release!:(value:number)=>void;const gate=new Promise<number>(resolve=>release=resolve);assert.equal(await boundedCompleteCount(()=>gate,x=>x,5),undefined);release(9)
|
||||
})
|
||||
Reference in new issue
Block a user