mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2025-12-11 20:02:09 +00:00
- t failing unit test
This commit is contained in:
parent
56ca5bf411
commit
4490aaa5fd
@ -1,4 +1,34 @@
|
|||||||
A pure "function", so this works:
|
# Requirements
|
||||||
|
|
||||||
|
`bash` and friends (`diff`, `grep`, `cat`)
|
||||||
|
|
||||||
|
# (Failing) Unit Test
|
||||||
|
|
||||||
|
```shell
|
||||||
|
./unit_test.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
# Texttest Fixture
|
||||||
|
|
||||||
|
```shell
|
||||||
|
./texttest_fixture.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
Specify days:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
./texttest_fixture.sh 30
|
||||||
|
```
|
||||||
|
|
||||||
|
Verify againt `ThirtyDays/stdout.gr`
|
||||||
|
|
||||||
|
```shell
|
||||||
|
./verify.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
## BTW
|
||||||
|
|
||||||
|
BTW, the script is a pure "function", so this works:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
$ echo -e 'Aged Brie,3,5\nOther Item,4,5' |\
|
$ echo -e 'Aged Brie,3,5\nOther Item,4,5' |\
|
||||||
@ -7,4 +37,4 @@ $ echo -e 'Aged Brie,3,5\nOther Item,4,5' |\
|
|||||||
./gilded_rose.sh
|
./gilded_rose.sh
|
||||||
Aged Brie,0,8
|
Aged Brie,0,8
|
||||||
Other Item,1,2
|
Other Item,1,2
|
||||||
```
|
```
|
||||||
|
|||||||
21
bash/unit_test.sh
Executable file
21
bash/unit_test.sh
Executable file
@ -0,0 +1,21 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
GILDED_ROSE_SCRIPT="./gilded_rose.sh"
|
||||||
|
|
||||||
|
get_name() {
|
||||||
|
grep -o '^[^|]*'
|
||||||
|
}
|
||||||
|
|
||||||
|
assert_equals() {
|
||||||
|
local expected="$1"
|
||||||
|
diff -u - <(echo "$expected")
|
||||||
|
}
|
||||||
|
|
||||||
|
test_foo() {
|
||||||
|
echo "foo|0|0" |
|
||||||
|
bash "$GILDED_ROSE_SCRIPT" |
|
||||||
|
get_name |
|
||||||
|
assert_equals "fixme"
|
||||||
|
}
|
||||||
|
|
||||||
|
test_foo
|
||||||
@ -1,3 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
./texttest_fixture.sh 30 | diff -u - ../texttests/ThirtyDays/stdout.gr
|
./texttest_fixture.sh 30 |
|
||||||
|
diff -u - ../texttests/ThirtyDays/stdout.gr &&
|
||||||
|
echo "✅ looks good" ||
|
||||||
|
(echo "❌ failed" && exit 1)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user