-
Notifications
You must be signed in to change notification settings - Fork 2
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 #29 from wearefuturegov/feature/tests-and-node-ver…
…sion Feature/tests and node version
- Loading branch information
Showing
45 changed files
with
4,671 additions
and
2,266 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
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 |
---|---|---|
|
@@ -28,6 +28,7 @@ yarn-error.log* | |
.idea | ||
.vscode | ||
.ruby-lsp | ||
coverage | ||
|
||
# heroku | ||
Procfile |
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,23 @@ | ||
name: Run tests | ||
on: push | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: lts/Iron | ||
|
||
- name: Install dependencies | ||
run: npm ci | ||
|
||
- name: Run tests | ||
run: npm run test | ||
|
||
- name: Upload coverage reports to Codecov | ||
uses: codecov/[email protected] | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
slug: wearefuturegov/outpost-api-service |
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,6 @@ | ||
node_modules | ||
.env | ||
/environment/artifacts | ||
.DS_Store | ||
.DS_Store | ||
coverage | ||
logs |
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 +1 @@ | ||
v16.18.0 | ||
lts/Iron |
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
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,5 +1,6 @@ | ||
# TODO | ||
|
||
- [ ] Automate tests with docker and github actions | ||
- [x] Automate tests with docker and github actions | ||
- [ ] Automatic linter on commit and PR's | ||
- [x] An option to push some dummy data to the API | ||
- [ ] Add support for csv export https://developers.openreferraluk.org/API-Guidance/ |
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,64 @@ | ||
{ | ||
"results": [ | ||
{ | ||
"address_components": [ | ||
{ | ||
"long_name": "London", | ||
"short_name": "London", | ||
"types": ["locality", "political"] | ||
}, | ||
{ | ||
"long_name": "London", | ||
"short_name": "London", | ||
"types": ["postal_town"] | ||
}, | ||
{ | ||
"long_name": "Greater London", | ||
"short_name": "Greater London", | ||
"types": ["administrative_area_level_2", "political"] | ||
}, | ||
{ | ||
"long_name": "England", | ||
"short_name": "England", | ||
"types": ["administrative_area_level_1", "political"] | ||
}, | ||
{ | ||
"long_name": "United Kingdom", | ||
"short_name": "GB", | ||
"types": ["country", "political"] | ||
} | ||
], | ||
"formatted_address": "London, UK", | ||
"geometry": { | ||
"bounds": { | ||
"northeast": { | ||
"lat": 51.6723432, | ||
"lng": 0.148271 | ||
}, | ||
"southwest": { | ||
"lat": 51.38494009999999, | ||
"lng": -0.3514683 | ||
} | ||
}, | ||
"location": { | ||
"lat": 51.5072178, | ||
"lng": -0.1275862 | ||
}, | ||
"location_type": "APPROXIMATE", | ||
"viewport": { | ||
"northeast": { | ||
"lat": 51.6723432, | ||
"lng": 0.148271 | ||
}, | ||
"southwest": { | ||
"lat": 51.38494009999999, | ||
"lng": -0.3514683 | ||
} | ||
} | ||
}, | ||
"place_id": "ChIJdd4hrwug2EcRmSrV3Vo6llI", | ||
"types": ["locality", "political"] | ||
} | ||
], | ||
"status": "OK" | ||
} |
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,47 @@ | ||
const { MongoClient } = require("mongodb") | ||
const { connect, db } = require("./../../src/db") | ||
const logger = require("./../../utils/logger") | ||
|
||
jest.mock("mongodb") | ||
jest.mock("./../../utils/logger") | ||
|
||
describe("db", () => { | ||
describe("connect", () => { | ||
it.todo("should connect to the database and call the callback with the db") | ||
// it("should connect to the database and call the callback with the db", async () => { | ||
// const mockDb = { databaseName: "outpost_api_development" } | ||
// const mockClient = { db: jest.fn().mockReturnValue(mockDb) } | ||
// MongoClient.connect.mockResolvedValue(mockClient) | ||
|
||
// const cb = jest.fn() | ||
// await connect(cb) | ||
|
||
// expect(MongoClient.connect).toHaveBeenCalledWith(process.env.DB_URI) | ||
// expect(mockClient.db).toHaveBeenCalled() | ||
// expect(cb).toHaveBeenCalledWith(mockDb) | ||
// }) | ||
|
||
it.todo("should log an error if the connection fails") | ||
// it("should log an error if the connection fails", async () => { | ||
// const error = new Error("Connection failed") | ||
// MongoClient.connect.mockRejectedValue(error) | ||
|
||
// const cb = jest.fn() | ||
// await connect(cb) | ||
|
||
// expect(logger.error).toHaveBeenCalledWith(error) | ||
// }) | ||
|
||
it.todo("should warn you if it connects but the database is 'test'") | ||
}) | ||
|
||
describe("db", () => { | ||
it("should throw an error if not connected", () => { | ||
expect(() => db()).toThrow( | ||
"db() called without being connected to the database. Please connect first, see application logs for more details." | ||
) | ||
}) | ||
|
||
it.todo("should return the db if connected") | ||
}) | ||
}) |
Oops, something went wrong.