Spaces:
Runtime error
Runtime error
Download test/adminAuthService.test.js from faridaqurr/tinfo-web-server: direct link, hf CLI and curl.
- Browser
- Download file 659 Bytes
-
https://huggingface.co/spaces/faridaqurr/tinfo-web-server/resolve/main/test/adminAuthService.test.js
- Command line
-
hf download hf://spaces/faridaqurr/tinfo-web-server/test/adminAuthService.test.js
-
curl -L -o adminAuthService.test.js https://huggingface.co/spaces/faridaqurr/tinfo-web-server/resolve/main/test/adminAuthService.test.js
659 Bytes
| const test = require('node:test'); | |
| const assert = require('node:assert/strict'); | |
| test('ensureAdminInitialized does not reset promise between concurrent calls', async () => { | |
| let bootstrapRunCount = 0; | |
| const fakeEnsure = (() => { | |
| let _promise = null; | |
| return () => { | |
| if (!_promise) { | |
| _promise = (async () => { | |
| bootstrapRunCount++; | |
| await new Promise(resolve => setTimeout(resolve, 10)); | |
| })(); | |
| } | |
| return _promise; | |
| }; | |
| })(); | |
| await Promise.all([fakeEnsure(), fakeEnsure(), fakeEnsure()]); | |
| assert.equal(bootstrapRunCount, 1, 'bootstrap must only run once even with concurrent calls'); | |
| }); | |