Skip to content

Commit

Permalink
feat: add stepwise test folders
Browse files Browse the repository at this point in the history
  • Loading branch information
techsavvyash committed Mar 3, 2024
1 parent ce7a629 commit efac4ad
Show file tree
Hide file tree
Showing 38 changed files with 9,382 additions and 1,267 deletions.
2 changes: 1 addition & 1 deletion docs/tutorials/09.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ module.exports = executeSELECTQuery;
> 💡**Do it yourself**: Implement the `performInnerJoin`, `performLeftJoin`, `performRightJoin` and update the `executeSELECTQuery` function.
### 9.3 Adding Tests for LEFT and RIGHT JOINs
- Given the number of tests that we will have, would be good to refactor them in separate files. Consider creating `csvReader.test.js`, `queryExecuter.test.js`, and `queryParser.test.js` files in the `tests` folder and segrate the tests accordingly.
- Given the number of tests that we will have, would be good to refactor them in separate files. Consider creating `csvReader.test.js`, `queryExecutor.test.js`, and `queryParser.test.js` files in the `tests` folder and segrate the tests accordingly.

> 💡**Do it yourself**: Refactor tests
Expand Down
6 changes: 3 additions & 3 deletions docs/tutorials/17.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ Add a function called `parseINSERTQuery` to the `queryParser.js` file. This func
```

### 17.2 Update the Query Executer
Add a function called `executeINSERTQuery` to the `queryExecuter.js` file. This function should take a query object as input and insert the data into the CSV file. The function should return a promise that resolves to the number of rows inserted.
Add a function called `executeINSERTQuery` to the `queryExecutor.js` file. This function should take a query object as input and insert the data into the CSV file. The function should return a promise that resolves to the number of rows inserted.


### 17.3. Make sure the following test passes

Create this test in a file called `tests/insertExecuter.test.js`

```javascript
const { executeINSERTQuery } = require('../src/queryExecuter');
const { readCSV, writeCSV } = require('../src/csvStorage');
const { executeINSERTQuery } = require('../src/queryExecutor');
const { readCSV, writeCSV } = require('../src/csvReader');
const fs = require('fs');

// Helper function to create grades.csv with initial data
Expand Down
6 changes: 3 additions & 3 deletions docs/tutorials/18.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ It should return an object with the following structure:
### 18.2 Update the Executer to Handle DELETE Statements

```javascript
// src/queryExecuter.js
// src/queryExecutor.js

async function executeDELETEQuery(query) {
const { table, whereClauses } = parseDeleteQuery(query);
Expand Down Expand Up @@ -47,8 +47,8 @@ module.exports = { executeSELECTQuery, executeINSERTQuery, executeDELETEQuery };
Create this test in a file called `tests/deleteExecuter.test.js`

```javascript
const { executeDELETEQuery } = require('../src/queryExecuter');
const { readCSV, writeCSV } = require('../src/csvStorage');
const { executeDELETEQuery } = require('../src/queryExecutor');
const { readCSV, writeCSV } = require('../src/csvReader');
const fs = require('fs');

// Helper function to create courses.csv with initial data
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/19.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Example implementation in cli.js:

```javascript
const readline = require('readline');
const { executeSELECTQuery, executeINSERTQuery, executeDELETEQuery } = require('./queryExecuter');
const { executeSELECTQuery, executeINSERTQuery, executeDELETEQuery } = require('./queryExecutor');

const rl = readline.createInterface({
input: process.stdin,
Expand Down
20 changes: 20 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,26 @@
},
"scripts": {
"test": "jest",
"test:1": "jest --testPathPattern=./tests/step-1",
"test:2": "jest --testPathPattern=./tests/step-2",
"test:3": "jest --testPathPattern=./tests/step-3",
"test:4": "jest --testPathPattern=./tests/step-4",
"test:5": "jest --testPathPattern=./tests/step-5",
"test:6": "jest --testPathPattern=./tests/step-6",
"test:7": "jest --testPathPattern=./tests/step-7",
"test:8": "jest --testPathPattern=./tests/step-8",
"test:9": "jest --testPathPattern=./tests/step-9",
"test:10": "jest --testPathPattern=./tests/step-10",
"test:11": "jest --testPathPattern=./tests/step-11",
"test:12": "jest --testPathPattern=./tests/step-12",
"test:13": "jest --testPathPattern=./tests/step-13",
"test:14": "jest --testPathPattern=./tests/step-14",
"test:15": "jest --testPathPattern=./tests/step-15",
"test:16": "jest --testPathPattern=./tests/step-16",
"test:17": "jest --testPathPattern=./tests/step-17",
"test:18": "jest --testPathPattern=./tests/step-18",
"test:19": "jest --testPathPattern=./tests/step-19",
"test:20": "jest --testPathPattern=./tests/step-20",
"test-verbose": "jest --verbose",
"server": "node ./src/server.js"
},
Expand Down
42 changes: 0 additions & 42 deletions tests/csvReader.test.js

This file was deleted.

102 changes: 0 additions & 102 deletions tests/insertExecuter.test.js

This file was deleted.

Loading

0 comments on commit efac4ad

Please sign in to comment.