Skip to content

Commit

Permalink
Merge pull request #28 from 50Fifty/hotfix/restructure-folders
Browse files Browse the repository at this point in the history
Restructure folders again.
  • Loading branch information
50Fifty authored Dec 22, 2023
2 parents 0251821 + f3be708 commit 91a8803
Show file tree
Hide file tree
Showing 26 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- name: Create serviceAccountKey.json
env:
SERVICE_ACCOUNT_KEY: ${{ secrets.SERVICE_ACCOUNT_KEY }}
run: echo $SERVICE_ACCOUNT_KEY | base64 -di > ./functions/tests/configs/serviceAccountKey.json
run: echo $SERVICE_ACCOUNT_KEY | base64 -di > ./extension/tests/configs/serviceAccountKey.json

- name: Run unit tests
env:
Expand Down Expand Up @@ -63,5 +63,5 @@ jobs:
# PROJECT_ID: ${{ secrets.PROJECT_ID }}
# FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
# run: |
# cd functions/tests/system-tests
# cd extension/tests/system-tests
# firebase emulators:exec --project $PROJECT_ID "npm run test:system"
2 changes: 1 addition & 1 deletion .mocharc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"require": "ts-node/register",
"extensions": ["ts", "tsx"],
"watch-files": [
"functions/src"
"extension/src"
]
}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Contributions to this extension are welcome! Feel free to submit issues, feature
All tests are written with [Mocha](https://mochajs.org/).

### Unit Tests
The unit tests target the performBackup function in `functions/src/index.ts`.
The unit tests target the performBackup function in `extension/src/index.ts`.

Unit tests can be run locally. It uses fake data and mocks to simulate the Firebase Authentication and Cloud Storage services.

Expand All @@ -85,7 +85,7 @@ To run the integration tests, run the following command:
### System Tests
To run the system tests, you first need to [set up a Firebase project](https://firebase.google.com/docs/projects/learn-more) and [install the Firebase CLI](https://firebase.google.com/docs/cli#install_the_firebase_cli).

1. Create a `.env` file in `functions/tests/system-tests/configs` with the following contents:
1. Create a `.env` file in `extension/tests/system-tests/configs` with the following contents:

```
PROJECT_ID="<project id>" # Optional: Project ID of the Firebase project to test with, if you want to test with a live project
Expand All @@ -94,7 +94,7 @@ To run the system tests, you first need to [set up a Firebase project](https://f
```
You can refer to the `sample.env` file in the same folder for an example.
2. Optional: Download a service account key for the Firebase project you want to test with and save it as `functions/tests/configs/serviceAccountKey.json`. This is required if you want to test the extension with a live Firebase project in addition to using the fakes.
2. Optional: Download a service account key for the Firebase project you want to test with and save it as `extension/tests/configs/serviceAccountKey.json`. This is required if you want to test the extension with a live Firebase project in addition to using the fakes.
3. Optional: Start the Firebase Emulator Suite by running the below command in the `auth-scheduled-backup` directory. This is required if you want to run the tests that use the Firebase Emulator Suite.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export class FakeAuthService implements AuthService {
private users: UserRecord[];

constructor({ num = 0 }: { num?: number } = {}) {
this.users = JSON.parse(fs.readFileSync('functions/src/services/fakes/mock_auth_data.json', 'utf8')).slice(0, num);
this.users = JSON.parse(fs.readFileSync('extension/src/services/fakes/mock_auth_data.json', 'utf8')).slice(0, num);
}

async *listAllUsers({ perBatchCount = 1000 }: { perBatchCount?: number } = {}): AsyncGenerator<UserRecord[]> {
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as dotenv from 'dotenv';
import * as fs from "fs";

export const serviceAccountKeyFilePath = "functions/tests/configs/serviceAccountKey.json"
export const serviceAccountKeyFilePath = "extension/tests/configs/serviceAccountKey.json"
export const serviceAccountKeyExists = fs.existsSync(serviceAccountKeyFilePath);

dotenv.config({ path: "functions/tests/configs/.env" });
dotenv.config({ path: "extension/tests/configs/.env" });

if (!process.env.PROJECT_ID && serviceAccountKeyExists) {
throw new Error('Service Account Key exists but PROJECT_ID not set in .env file.');
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "functions",
"name": "extension",
"scripts": {
"lint": "eslint \"functions/src/**/*\"",
"lint:fix": "eslint \"functions/src/**/*\" --fix",
"lint": "eslint \"extension/src/**/*\"",
"lint:fix": "eslint \"extension/src/**/*\" --fix",
"build": "npm run lint:fix && tsc",
"build:watch": "tsc --watch",
"test:unit": "mocha -r ts-node/register functions/tests/unit-tests/**/*.spec.ts",
"test:integration": "mocha -r ts-node/register functions/tests/integration-tests/**/*.spec.ts",
"test:system": "mocha -r ts-node/register functions/tests/system-tests/**/*.spec.ts"
"test:unit": "mocha -r ts-node/register extension/tests/unit-tests/**/*.spec.ts",
"test:integration": "mocha -r ts-node/register extension/tests/integration-tests/**/*.spec.ts",
"test:system": "mocha -r ts-node/register extension/tests/system-tests/**/*.spec.ts"
},
"main": "lib/index.js",
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
},
"compileOnSave": true,
"include": [
"functions/src"
"extension/src"
],
}

0 comments on commit 91a8803

Please sign in to comment.