-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: expand on unit testing for topographic stac creation
- Loading branch information
Showing
4 changed files
with
77 additions
and
4 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,72 @@ | ||
import assert from 'node:assert'; | ||
import { beforeEach, describe, it } from 'node:test'; | ||
|
||
import { fsa, FsMemory, LogConfig } from '@basemaps/shared'; | ||
import { TestTiff } from '@basemaps/test'; | ||
import { StacCollection } from 'stac-ts'; | ||
|
||
import { TopoStacItem } from '../../stac.js'; | ||
Check failure on line 8 in packages/cogify/src/cogify/cli/__test__/cli.topo.test.ts
|
||
import { TopoStacCreationCommand } from '../cli.topo.js'; | ||
|
||
describe('cli.topo', () => { | ||
const fsMemory = new FsMemory(); | ||
|
||
beforeEach(async () => { | ||
LogConfig.get().level = 'silent'; | ||
fsa.register('memory://', fsMemory); | ||
fsMemory.files.clear(); | ||
|
||
await fsa.write(new URL('memory://source/CJ10_GRIDLESS_GeoTifv1-00.tif'), fsa.readStream(TestTiff.Nztm2000)); | ||
await fsa.write(new URL('memory://source/CJ10_GRIDLESS_GeoTifv1-01.tif'), fsa.readStream(TestTiff.Nztm2000)); | ||
}); | ||
|
||
const baseArgs = { | ||
paths: [new URL('memory://source/')], | ||
target: new URL('memory://target/'), | ||
mapSeries: 'topo50', | ||
latestOnly: false, | ||
title: undefined, | ||
output: undefined, | ||
|
||
// extra logging arguments | ||
verbose: false, | ||
extraVerbose: false, | ||
}; | ||
|
||
it('should generate a covering', async () => { | ||
const ret = await TopoStacCreationCommand.handler({ ...baseArgs }).catch((e) => String(e)); | ||
assert.equal(ret, undefined); // no errors returned | ||
|
||
const files = [...fsMemory.files.keys()]; | ||
files.sort(); | ||
|
||
// console.log(files); | ||
|
||
assert.deepEqual(files, [ | ||
'memory://source/CJ10_GRIDLESS_GeoTifv1-00.tif', | ||
'memory://source/CJ10_GRIDLESS_GeoTifv1-01.tif', | ||
'memory://target/topo50/gridless_600dpi/2193/CJ10_v1-00.json', | ||
'memory://target/topo50/gridless_600dpi/2193/CJ10_v1-01.json', | ||
'memory://target/topo50/gridless_600dpi/2193/collection.json', | ||
'memory://target/topo50_latest/gridless_600dpi/2193/CJ10.json', | ||
'memory://target/topo50_latest/gridless_600dpi/2193/collection.json', | ||
]); | ||
|
||
const collectionJson = await fsa.readJson<StacCollection>( | ||
new URL('memory://target/topo50/gridless_600dpi/2193/collection.json'), | ||
); | ||
assert.equal(collectionJson['description'], 'Topographic maps of New Zealand'); | ||
assert.equal(collectionJson['linz:slug'], 'topo50-new-zealand-mainland'); | ||
assert.equal(collectionJson['linz:region'], 'new-zealand'); | ||
|
||
const latestItemUrl = new URL('memory://target/topo50_latest/gridless_600dpi/2193/CJ10.json'); | ||
const latestVersion = await fsa.readJson<StacCollection>(latestItemUrl); | ||
|
||
// Latest file should be derived_from the source file | ||
const derived = latestVersion.links.filter((f) => f.rel === 'derived_from'); | ||
assert.equal(derived.length, 1); | ||
|
||
const derivedFile = new URL(derived[0].href, latestItemUrl); | ||
assert.equal(derivedFile.href, 'memory://target/topo50/gridless_600dpi/2193/CJ10_v1-01.json'); | ||
}); | ||
}); |
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