-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test (libpostal): try adding test to libpostal
- Loading branch information
1 parent
12a6585
commit 2ec663b
Showing
4 changed files
with
93 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env bash | ||
|
||
## Script base of the libpostal github action | ||
## https://github.com/openvenues/node-postal/blob/master/.github/workflows/push.yml | ||
|
||
# Install required dependencies to build libpostal | ||
sudo apt-get update | ||
sudo apt-get install build-essential curl autoconf automake libtool pkg-config | ||
|
||
# Create working directory | ||
sudo mkdir -p /code /data /deps | ||
sudo chown "$USER":"$USER" /code /data /deps | ||
|
||
# Install lib postal | ||
cd /code || exit | ||
git clone https://github.com/openvenues/libpostal | ||
cd libpostal || exit | ||
git reset --hard 8f2066b ## Reset to a fixed commit https://github.com/openvenues/libpostal/commit/8f2066b1d30f4290adf59cacc429980f139b8545 | ||
./bootstrap.sh | ||
./configure --datadir=/data --prefix=/deps --bindir=/deps || cat config.log | ||
make -j4 | ||
make install |
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,23 @@ | ||
import from from 'from'; | ||
|
||
/** | ||
* Helper function used to call ezs in each test | ||
* @param ezsRuntime {(name: string, options: any, environment?: unknown) => NodeJS.WritableStream} | ||
* @param dataSet {Array<unknown>} | ||
* @param functionName {string} | ||
* @param [options] {any} | ||
* @returns {Promise<Array<unknown>>} | ||
*/ | ||
const runEzs = (ezsRuntime, dataSet, functionName, options) => new Promise((resolve) => { | ||
const result = []; | ||
from(dataSet) | ||
.pipe(ezsRuntime(functionName, options)) | ||
.on('data', (chunk) => { | ||
result.push(chunk); | ||
}) | ||
.on('end', () => { | ||
resolve(result); | ||
}); | ||
}); | ||
|
||
export default runEzs; |
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,41 @@ | ||
import ezs from '../../core/src'; | ||
import expandAddress from '../src/expand-address'; | ||
import expandAddressWith from '../src/expand-address-with'; | ||
import runEzs from '../test-utils/runEzs'; | ||
|
||
ezs.addPath(__dirname); | ||
|
||
describe('expandAddress', () => { | ||
|
||
beforeAll(() => { | ||
ezs.use({ expandAddress, expandAddressWith }); | ||
}); | ||
|
||
describe('expandAddress, simple object', () => { | ||
const simpleData = [ | ||
'Barboncino 781 Franklin Ave, Crown Heights, Brooklyn, NY 11238' | ||
]; | ||
|
||
it('should expandAddress', async () => { | ||
const result = await runEzs(ezs, simpleData, 'expandAddress'); | ||
|
||
expect(result[0]).not.toBeNull(); | ||
|
||
console.log(result); | ||
}); | ||
}); | ||
|
||
describe('expandAddressWith, simple object', () => { | ||
const simpleData = [ | ||
{value: 'Barboncino 781 Franklin Ave, Crown Heights, Brooklyn, NY 11238'} | ||
]; | ||
|
||
it('should expandAddressWith (path = value)', async () => { | ||
const result = await runEzs(ezs, simpleData, 'expandAddressWith', {path: 'value'}); | ||
|
||
expect(result[0]).not.toBeNull(); | ||
|
||
console.log(result); | ||
}); | ||
}); | ||
}); |