-
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.
Merge pull request #4 from shelfio/develop
V1.0.0
- Loading branch information
Showing
20 changed files
with
245 additions
and
128 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 |
---|---|---|
@@ -1,12 +1,12 @@ | ||
orbs: | ||
node: circleci/[email protected].3 | ||
node: circleci/[email protected].2 | ||
|
||
version: 2.1 | ||
|
||
parameters: | ||
node_version: | ||
type: string | ||
default: '16.15.1' | ||
default: '16.17.0' | ||
|
||
commands: | ||
install_deps: | ||
|
@@ -17,16 +17,18 @@ commands: | |
cache-only-lockfile: true | ||
app-dir: ~/repo | ||
override-ci-command: yarn install --pure-lockfile --no-progress | ||
- run: sudo apt update -q && sudo apt install postgresql-12 | ||
|
||
jobs: | ||
build: | ||
executor: | ||
name: node/default | ||
tag: << pipeline.parameters.node_version >> | ||
tag: <<pipeline.parameters.node_version>> | ||
working_directory: ~/repo | ||
steps: | ||
- checkout | ||
- install_deps | ||
- run: yarn test | ||
- run: yarn build | ||
- run: sudo yarn test | ||
- run: yarn type-check | ||
- run: yarn lint:ci |
Empty file.
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 |
---|---|---|
@@ -1,30 +1,11 @@ | ||
.vscode/ | ||
.serverless/ | ||
.idea/ | ||
.idea/aws.xml | ||
coverage/ | ||
lib/ | ||
node_modules/ | ||
|
||
*.log | ||
junit.xml | ||
draft.js | ||
*.draft.js | ||
draft.ts | ||
*.draft.ts | ||
lib/ | ||
temp | ||
yarn.lock | ||
|
||
.env | ||
*.log | ||
.DS_Store | ||
|
||
# User-specific stuff | ||
.idea/**/workspace.xml | ||
.idea/**/tasks.xml | ||
.idea/**/usage.statistics.xml | ||
.idea/**/shelf | ||
|
||
# File-based project format | ||
*.iws | ||
|
||
.idea/$CACHE_FILE$ | ||
.idea/$PRODUCT_WORKSPACE_FILE$ | ||
.idea/.gitignore | ||
globalConfig.json | ||
!.husky/_/husky.sh |
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
yarn lint-staged --shell "/bin/sh" --verbose | ||
|
||
yarn lint-staged |
This file was deleted.
Oops, something went wrong.
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,7 @@ | ||
import cwd from 'cwd'; | ||
|
||
module.exports = { | ||
seedPath: `${cwd()}/test/seed.sql`, | ||
version: 12, | ||
port: 5555, | ||
}; |
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,3 @@ | ||
const preset = require('./lib'); | ||
|
||
module.exports = preset; |
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,56 @@ | ||
# jest-postgres [![CircleCI](https://circleci.com/gh/shelfio/jest-postgres/tree/master.svg?style=svg)](https://circleci.com/gh/shelfio/jest-postgres/tree/master) ![](https://img.shields.io/badge/code_style-prettier-ff69b4.svg) [![npm (scoped)](https://img.shields.io/npm/v/@shelf/jest-postgres.svg)](https://www.npmjs.com/package/@shelf/jest-postgres) | ||
|
||
> Jest preset to run Postgres server | ||
## Usage | ||
|
||
### 0. Install | ||
|
||
``` | ||
$ yarn add @shelf/jest-postgres --dev | ||
``` | ||
|
||
### 1. Create `jest.config.js` | ||
|
||
```js | ||
module.exports = { | ||
preset: '@shelf/jest-postgres' | ||
}; | ||
``` | ||
|
||
If you have a custom `jest.config.js` make sure you remove `testEnvironment` property, otherwise it will conflict with the preset. | ||
|
||
### 2. Create `jest-postgres-config.js` | ||
|
||
```js | ||
import cwd from 'cwd'; | ||
|
||
module.exports = { | ||
seedPath: `${cwd()}/test/seed.sql`, | ||
version: 14, | ||
port: 5555, | ||
}; | ||
``` | ||
Find `seed.sql` example in `./test` folder of this repo | ||
### 4. PROFIT! Write tests | ||
|
||
```js | ||
it(); | ||
``` | ||
|
||
## See Also | ||
|
||
- [jest-dynamodb](https://github.com/shelfio/jest-dynamodb) | ||
|
||
## Publish | ||
|
||
```sh | ||
$ git checkout master | ||
$ yarn version | ||
$ yarn publish | ||
$ git push origin master --tags | ||
``` | ||
|
||
## License | ||
|
||
MIT © [Shelf](https://shelf.io) |
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 |
---|---|---|
@@ -1,8 +1,4 @@ | ||
{ | ||
"extends": ["config:base"], | ||
"labels": ["dependencies", "backend"], | ||
"ignoreDeps": [ | ||
"cimg/node", | ||
"@types/node" | ||
] | ||
"labels": ["dependencies", "backend"] | ||
} |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
export function getFoo(): string { | ||
return 'bar'; | ||
} | ||
import {resolve} from 'path'; | ||
|
||
module.exports = { | ||
globalSetup: resolve(__dirname, './setup.js'), | ||
globalTeardown: resolve(__dirname, './teardown.js'), | ||
}; |
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,10 @@ | ||
import {start} from '@shelf/postgres-local'; | ||
import cwd from 'cwd'; | ||
|
||
const config = require(`${cwd()}/jest-postgres-config.js`); | ||
|
||
module.exports = async function startPostgres() { | ||
await start(config); | ||
|
||
return true; | ||
}; |
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,8 @@ | ||
import {stop} from '@shelf/postgres-local'; | ||
import cwd from 'cwd'; | ||
|
||
const config = require(`${cwd()}/jest-postgres-config.js`); | ||
|
||
module.exports = async function stopPostgres() { | ||
await stop(config); | ||
}; |
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,35 @@ | ||
import {closeConnection, getClient} from './client'; | ||
|
||
describe('#getClient', () => { | ||
const client = getClient({ | ||
host: 'localhost', | ||
port: 5555, | ||
username: '', | ||
password: '', | ||
database: 'postgres', | ||
}); | ||
|
||
it('should use 5555 port and insert records', async () => { | ||
await client.withSchema('test').table('model1').insert({ | ||
id: 'unique', | ||
type: 'some text', | ||
text: 'should be text', | ||
}); | ||
|
||
const res = await client.withSchema('test').table('model1').select('*').where({id: 'unique'}); | ||
|
||
expect(res).toEqual([ | ||
{ | ||
id: 'unique', | ||
json: null, | ||
somebool: null, | ||
text: 'should be text', | ||
type: 'some text', | ||
updated_at: null, | ||
vector: null, | ||
}, | ||
]); | ||
|
||
await closeConnection(); | ||
}); | ||
}); |
Oops, something went wrong.