mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2025-12-11 20:02:09 +00:00
merge readme files
This commit is contained in:
parent
a2c1d7140b
commit
a57022e13c
@ -6,36 +6,57 @@ You'll need:
|
||||
To use remote / local dockerized database, add ``` --host --port --username``` parameters to plsql invocation.
|
||||
|
||||
# Setup
|
||||
## With docker
|
||||
Run `docker-compose up -d <TEST_FRAMEWORK>` to start, and `docker-compose exec <TEST_FRAMEWORK> bash` to enter in container.
|
||||
`<TEST_FRAMEWORK>` is the testing framework name. Two values are possible: `pgunit` or `pgtap`
|
||||
|
||||
## Without docker
|
||||
In shell:
|
||||
- create database: ```createdb gilded_rose```
|
||||
- create item table (structure): ```psql -d gilded_rose -f ./structure/create.sql```
|
||||
- load code into database: ```psql -d gilded_rose -f ./src/update_quality.sql ```
|
||||
- create database: ```createdb kata```
|
||||
- create item table (structure): ```psql -d kata -f ./src/item.sql```
|
||||
- create procedure to help to add item: ```psql -d kata -f ./src/new_item.sql```
|
||||
- load code into database: ```psql -d kata -f ./src/update_quality.sql ```
|
||||
|
||||
If you get this message```LINE 1: CREATE OR REPLACE PROCEDURE public.update_quality()```, your PostgreSQL version may under 11, consider upgrading.
|
||||
|
||||
# Run
|
||||
In shell:
|
||||
- load manual test data into database: ```psql -d gilded_rose -f ./test/manual/load.sql```
|
||||
- connect to CLI: ```psql -d gilded_rose```
|
||||
- connect to CLI: ```psql -d kata```
|
||||
- add item: ```CALL new_item('+5 Dexterity Vest', 10, 20);```
|
||||
- check item state: ```SELECT * FROM item;```
|
||||
- execute item update: ```CALL update_quality();```
|
||||
- check item state: ```SELECT * FROM item;```
|
||||
- empty table : ```TRUNCATE TABLE item;```
|
||||
|
||||
# Kata
|
||||
`src/update_quality.sql` contains code to refactor.
|
||||
|
||||
# Test
|
||||
|
||||
## Using pgTAP
|
||||
|
||||
### Requirements
|
||||
Install pgTAP [instructions here](https://pgtap.org/documentation.html#installation)
|
||||
It's already installed with docker
|
||||
|
||||
```item``` table is supposed to be empty.
|
||||
If not, it would cause a (false positive)[https://en.wikipedia.org/wiki/False_positives_and_false_negatives]
|
||||
|
||||
### Execute
|
||||
In shell, execute ```pg_prove --dbname gilded_rose test/pgtap/*.sql```.
|
||||
You should get ```test/pgtap/template.sql .. ok All tests successful.```
|
||||
In shell, execute ```psql -d kata -f src/update_quality.sql && pg_prove pgtap/test_*.sql```.
|
||||
You should get ```pgtap/test_case_update_quality.sql .. ok All tests successful.```
|
||||
|
||||
If you get this message ```ERROR: function plan(integer) does not exist LINE 1: SELECT PLAN(1);```, pgTAP is not working => check your pgTAP installation.
|
||||
If you get this message ```Failed test: 2 Parse errors: Bad plan. You planned 1 tests but ran 2.```, the item table contains data, interfering with the test => empty it, then run test again.
|
||||
|
||||
`pgtap/test_case_update_quality.sql` contains test examples.
|
||||
|
||||
## Using pgunit
|
||||
### Requirement
|
||||
Unit test framework used : pgunit (https://github.com/adrianandrei-ca/pgunit)
|
||||
It's already installed with docker
|
||||
|
||||
### Execute
|
||||
Run `docker-compose up -d pgunit` to start, and `docker-compose exec pgunit bash` to enter in container.
|
||||
You can run `cat src/update_quality.sql pgunit/run_tests.sql | psql -d kata -f -`
|
||||
|
||||
`pgunit/run_tests.sql` contains test examples.
|
||||
|
||||
@ -1,10 +0,0 @@
|
||||
## Requirement
|
||||
Testing on postgres 12
|
||||
Unit test framework used : pgunit (https://github.com/adrianandrei-ca/pgunit)
|
||||
|
||||
## Setup
|
||||
Run `docker-compose up -d` to start, and `docker-compose exec database bash` to enter in container.
|
||||
You can run `cat update_quality.sql run_tests.sql | psql -d kata -f -`
|
||||
|
||||
## Kata
|
||||
`update_quality.sql` contains code to refactor, and `run_tests.sql` contains test examples.
|
||||
Loading…
Reference in New Issue
Block a user