|
1 | 1 | -- Setup test table and read in student solution:
|
2 | 2 | .read ./test_setup.sql
|
3 |
| - |
4 | 3 | -- Test cases:
|
5 |
| -INSERT INTO tests (name, uuid, |
6 |
| - input, expected) |
7 |
| - VALUES |
8 |
| - ('no name given', '1cf3e15a-a3d7-4a87-aeb3-ba1b43bc8dce', |
9 |
| - '', 'One for you, one for me.'), |
10 |
| - ('a name given', 'b4c6dbb8-b4fb-42c2-bafd-10785abe7709', |
11 |
| - 'Alice', 'One for Alice, one for me.'), |
12 |
| - ('another name given', '3549048d-1a6e-4653-9a79-b0bda163e8d5', |
13 |
| - 'Bob', 'One for Bob, one for me.'); |
| 4 | +INSERT INTO |
| 5 | + tests (name, uuid, input, expected) |
| 6 | +VALUES |
| 7 | + ( |
| 8 | + 'no name given', |
| 9 | + '1cf3e15a-a3d7-4a87-aeb3-ba1b43bc8dce', |
| 10 | + '', |
| 11 | + 'One for you, one for me.' |
| 12 | + ), |
| 13 | + ( |
| 14 | + 'a name given', |
| 15 | + 'b4c6dbb8-b4fb-42c2-bafd-10785abe7709', |
| 16 | + 'Alice', |
| 17 | + 'One for Alice, one for me.' |
| 18 | + ), |
| 19 | + ( |
| 20 | + 'another name given', |
| 21 | + '3549048d-1a6e-4653-9a79-b0bda163e8d5', |
| 22 | + 'Bob', |
| 23 | + 'One for Bob, one for me.' |
| 24 | + ); |
14 | 25 |
|
15 | 26 | -- Comparison of user input and the tests updates the status for each test:
|
16 | 27 | UPDATE tests
|
17 |
| -SET status = 'pass' |
18 |
| -FROM (SELECT input, response FROM twofer) AS actual |
19 |
| -WHERE (actual.input, actual.response) = (tests.input, tests.expected); |
| 28 | +SET |
| 29 | + status = 'pass' |
| 30 | +FROM |
| 31 | + ( |
| 32 | + SELECT |
| 33 | + input, |
| 34 | + response |
| 35 | + FROM |
| 36 | + twofer |
| 37 | + ) AS actual |
| 38 | +WHERE |
| 39 | + (actual.input, actual.response) = (tests.input, tests.expected); |
20 | 40 |
|
21 | 41 | -- Write results and debug info:
|
22 | 42 | .read ./test_reporter.sql
|
0 commit comments