Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
141 changes: 0 additions & 141 deletions .github/expected_results/end2end.txt

This file was deleted.

8 changes: 4 additions & 4 deletions .github/workflows/end2end-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ jobs:
- name: Build
run: go build -v

- name: Run
run: ./GO4SQL -file test_file > output.txt
- name: Make Test Script Executable
run: chmod +x e2e/e2e_test.sh

- name: Check Result
run: diff output.txt ./.github/expected_results/end2end.txt
- name: Run Tests
run: e2e/e2e_test.sh
26 changes: 14 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ You can compile the project with ``go build``, this will create ``GO4SQL`` binar
Currently, there are 3 modes to chose from:

1. `File Mode` - You can specify file path with ``./GO4SQL -file file_path``, that will read the
input
data directly into the program and print the result.

input data directly into the program and print the result. In order to run one of e2e test files you can use:
```shell
go build; ./GO4SQL -file e2e/test_files/1_select_with_where_test
```
2. `Stream Mode` - With ``./GO4SQL -stream`` you can run the program in stream mode, then you
provide SQL commands
in your console (from standard input).
Expand All @@ -43,7 +44,15 @@ To run all the tests locally paste this in root directory:
go clean -testcache; go test ./...
```

### Docker
## E2E TESTS

There are integrated with Github actions e2e tests that can be found in: `.github/workflows/end2end-tests.yml` file.
Tests run files inside `e2e/test_files` directory through `GO4SQL`, save stdout into files, and finally compare
then with expected outputs inside `e2e/expected_outputs` directory.

To run e2e test locally, you can run script `./e2e/e2e_test.sh` if you're in the root directory.

## Docker

1. Pull docker image: `docker pull kajedot/go4sql:latest`
2. Run docker container in the interactive mode, remember to provide flag, for example:
Expand Down Expand Up @@ -302,18 +311,11 @@ go clean -testcache; go test ./...
This command will return the average of all values in the numerical column ``columnName`` of
``tableName``.

## E2E TEST

In root directory there is **test_file** containing input commands for E2E tests. File
**.github/expected_results/end2end.txt** has expected results for it.
This is integrated into github workflows.

## DOCKER

To build your docker image run this command in root directory:

```
shell
```shell
docker build -t go4sql:test .
```

Expand Down
22 changes: 22 additions & 0 deletions e2e/e2e_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

e2e_failed=false

for test_file in e2e/test_files/*_test; do
output_file="./e2e/$(basename "${test_file/_test/_output}")"
./GO4SQL -file "$test_file" > "$output_file"
expected_output="e2e/expected_outputs/$(basename "${test_file/_test/_expected_output}")"
diff "$output_file" "$expected_output"
if [ $? -ne 0 ]; then
echo "E2E test for: {$test_file} failed"
e2e_failed=true
fi
rm "./$output_file"
done

if [ "$e2e_failed" = true ]; then
echo "E2E tests failed."
exit 1
else
echo "All E2E tests passed."
fi
35 changes: 35 additions & 0 deletions e2e/expected_outputs/1_select_with_where_expected_output
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Table 'tbl' has been created
Data Inserted
Data Inserted
Data Inserted
+----------+------+-------+------+
| one | two | three | four |
+----------+------+-------+------+
| 'byebye' | NULL | 33 | 'e' |
+----------+------+-------+------+
+-----------+-------+
| one | three |
+-----------+-------+
| 'hello' | 11 |
| 'goodbye' | 22 |
+-----------+-------+
+----------+------+-------+------+
| one | two | three | four |
+----------+------+-------+------+
| 'byebye' | NULL | 33 | 'e' |
+----------+------+-------+------+
+-----------+------+-------+------+
| one | two | three | four |
+-----------+------+-------+------+
| 'goodbye' | 1 | 22 | 'w' |
| 'byebye' | NULL | 33 | 'e' |
+-----------+------+-------+------+
+---------+-----+-------+------+
| one | two | three | four |
+---------+-----+-------+------+
| 'hello' | 1 | 11 | 'q' |
+---------+-----+-------+------+
+-----+-----+-------+------+
| one | two | three | four |
+-----+-----+-------+------+
+-----+-----+-------+------+
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Table 'tbl' has been created
Data Inserted
Data Inserted
Data Inserted
+---------+-----+-------+------+
| one | two | three | four |
+---------+-----+-------+------+
| 'hello' | 1 | 11 | 'q' |
+---------+-----+-------+------+
+-----------+------+-------+------+
| one | two | three | four |
+-----------+------+-------+------+
| 'goodbye' | 1 | 22 | 'w' |
| 'byebye' | NULL | 33 | 'e' |
+-----------+------+-------+------+
+-----------+-----+-------+------+
| one | two | three | four |
+-----------+-----+-------+------+
| 'goodbye' | 1 | 22 | 'w' |
+-----------+-----+-------+------+
11 changes: 11 additions & 0 deletions e2e/expected_outputs/3_delete_expected_output
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Table 'tbl' has been created
Data Inserted
Data Inserted
Data Inserted
Data from 'tbl' has been deleted
+-----------+-----+-------+------+
| one | two | three | four |
+-----------+-----+-------+------+
| 'hello' | 1 | 11 | 'q' |
| 'goodbye' | 1 | 22 | 'w' |
+-----------+-----+-------+------+
11 changes: 11 additions & 0 deletions e2e/expected_outputs/4_orderby_expected_output
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Table 'tbl' has been created
Data Inserted
Data Inserted
Data Inserted
+-----------+
| one |
+-----------+
| 'byebye' |
| 'goodbye' |
| 'hello' |
+-----------+
12 changes: 12 additions & 0 deletions e2e/expected_outputs/5_update_expected_output
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Table 'tbl' has been created
Data Inserted
Data Inserted
Data Inserted
Table: 'tbl' has been updated
+-----------+------+-------+------+
| one | two | three | four |
+-----------+------+-------+------+
| 'hello' | 1 | 11 | 'q' |
| 'goodbye' | NULL | 22 | 'P' |
| 'byebye' | NULL | 33 | 'e' |
+-----------+------+-------+------+
13 changes: 13 additions & 0 deletions e2e/expected_outputs/6_select_distinct_expected_output
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Table 'tbl' has been created
Data Inserted
Data Inserted
Data Inserted
Data Inserted
Data Inserted
+-----------+------+-------+------+
| one | two | three | four |
+-----------+------+-------+------+
| 'hello' | 1 | 11 | 'q' |
| 'goodbye' | 1 | 22 | 'w' |
| 'byebye' | NULL | 33 | 'e' |
+-----------+------+-------+------+
2 changes: 2 additions & 0 deletions e2e/expected_outputs/7_drop_table_expected_output
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Table 'tbl' has been created
Table: 'tbl' has been dropped
30 changes: 30 additions & 0 deletions e2e/expected_outputs/8_select_with_join_expected_output
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Table 'table1' has been created
Table 'table2' has been created
Data Inserted
Data Inserted
Data Inserted
Data Inserted
+--------------+--------------+
| table1.value | table2.value |
+--------------+--------------+
| 'Value1' | NULL |
| NULL | 'Value2' |
| NULL | 'Value3' |
+--------------+--------------+
+--------------+--------------+
| table1.value | table2.value |
+--------------+--------------+
| NULL | 'Value2' |
+--------------+--------------+
+--------------+--------------+
| table1.value | table2.value |
+--------------+--------------+
| 'Value1' | NULL |
| NULL | 'Value2' |
+--------------+--------------+
+--------------+--------------+
| table1.value | table2.value |
+--------------+--------------+
| NULL | 'Value2' |
| NULL | 'Value3' |
+--------------+--------------+
Loading
Loading