-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Node: Add more tests, fix stream error on timeout
- Loading branch information
Showing
3 changed files
with
149 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
const test = require('ava') | ||
const {MapGen} = require('../ocmapgen') | ||
|
||
let empty = ` | ||
protected func InitializeMap(proplist map) | ||
{ | ||
return true; | ||
} | ||
` | ||
|
||
test('Multiple sequential', async t => { | ||
let mapgen = t.context.mapgen = new MapGen({ | ||
root: __dirname + '/../../openclonk/planet', | ||
map_type: 'Map.c', | ||
}) | ||
|
||
let {fg: fg1} = await mapgen.generate(empty) | ||
t.true(isPNG(fg1)) | ||
let {fg: fg2} = await mapgen.generate(empty) | ||
t.true(isPNG(fg2)) | ||
t.deepEqual(fg1, fg2) | ||
}) | ||
|
||
test('Multiple parallel calls (but sequential execution)', async t => { | ||
let mapgen = t.context.mapgen = new MapGen({ | ||
root: __dirname + '/../../openclonk/planet', | ||
map_type: 'Map.c', | ||
}) | ||
|
||
let m1 = mapgen.generate(empty) | ||
let m2 = mapgen.generate(empty) | ||
let {fg: fg1} = await m1 | ||
t.true(isPNG(fg1)) | ||
let {fg: fg2} = await m2 | ||
t.true(isPNG(fg2)) | ||
t.deepEqual(fg1, fg2) | ||
}) | ||
|
||
|
||
test.afterEach(t => { | ||
t.context.mapgen.end() | ||
}) | ||
|
||
function isPNG(buf) { | ||
return buf.toString('ascii', 1, 4) == 'PNG' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters