Skip to content

Commit

Permalink
tests: add tests and update fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan-gang committed Oct 17, 2024
1 parent fa05c65 commit a7950fa
Show file tree
Hide file tree
Showing 3 changed files with 665 additions and 428 deletions.
9 changes: 2 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,15 @@ test_concurrent_requests_with_kafka: build
dist/main.out


test_current:
test_all:
make test_base_with_kafka
make test_concurrent_requests_with_kafka
make test_describe_topic_partitions_with_kafka
make test_fetch_with_kafka

test_fetch_with_kafka: build
CODECRAFTERS_REPOSITORY_DIR=./internal/test_helpers/pass_all \
CODECRAFTERS_TEST_CASES_JSON="[{\"slug\":\"gs0\",\"tester_log_prefix\":\"stage-F1\",\"title\":\"Stage #F1: API Version with Fetch Key\"}, {\"slug\":\"dh6\",\"tester_log_prefix\":\"stage-F2\",\"title\":\"Stage #F2: Fetch with no topics\"}, {\"slug\":\"hn6\",\"tester_log_prefix\":\"stage-F3\",\"title\":\"Stage #F3: Fetch with unknown topic\"}, {\"slug\":\"cm4\",\"tester_log_prefix\":\"stage-F4\",\"title\":\"Stage #F4: Fetch with empty topic\"}, {\"slug\":\"eg2\",\"tester_log_prefix\":\"stage-F5\",\"title\":\"Stage #F5: Single Fetch from Disk\"}, {\"slug\":\"fd8\",\"tester_log_prefix\":\"stage-F6\",\"title\":\"Stage #F6: Multi Fetch from Disk\"}]" \
dist/main.out

test_75_with_kafka: build
CODECRAFTERS_REPOSITORY_DIR=./internal/test_helpers/pass_all \
CODECRAFTERS_TEST_CASES_JSON="[{\"slug\":\"fd8\",\"tester_log_prefix\":\"stage-F6\",\"title\":\"Stage #F6: Multi Fetch from Disk\"}]" \
CODECRAFTERS_TEST_CASES_JSON="[{\"slug\":\"gs0\",\"tester_log_prefix\":\"stage-F1\",\"title\":\"Stage #F1: API Version with Fetch Key\"}, {\"slug\":\"dh6\",\"tester_log_prefix\":\"stage-F2\",\"title\":\"Stage #F2: Fetch with no topics\"}, {\"slug\":\"hn6\",\"tester_log_prefix\":\"stage-F3\",\"title\":\"Stage #F3: Fetch with unknown topic\"}, {\"slug\":\"cm4\",\"tester_log_prefix\":\"stage-F4\",\"title\":\"Stage #F4: Fetch with empty topic\"}, {\"slug\":\"eg2\",\"tester_log_prefix\":\"stage-F5\",\"title\":\"Stage #F5: Single Fetch from Disk\"}, {\"slug\":\"fd8\",\"tester_log_prefix\":\"stage-F6\",\"title\":\"Stage #F6: Multi Fetch from Disk\"}, ]" \
dist/main.out

test:
Expand Down
4 changes: 2 additions & 2 deletions internal/stages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestStages(t *testing.T) {
NormalizeOutputFunc: normalizeTesterOutput,
},
"fetch_pass": {
StageSlugs: []string{"gs0", "dh6", "hn6", "cm4"},
StageSlugs: []string{"gs0", "dh6", "hn6", "cm4", "eg2", "fd8"},
CodePath: "./test_helpers/pass_all",
ExpectedExitCode: 0,
StdoutFixturePath: "./test_helpers/fixtures/fetch/pass",
Expand All @@ -60,7 +60,7 @@ func normalizeTesterOutput(testerOutput []byte) []byte {
"Name": {regexp.MustCompile(`✓ Topic Name: [0-9A-Za-z]{3}`)},
"UUID": {regexp.MustCompile(`✓ Topic UUID: [0-9]{8}-[0-9]{4}-[0-9]{4}-[0-9]{4}-[0-9]{12}`)},
"value_length": {regexp.MustCompile(`- .value_length \([0-9]{1,}\)`)},
"value": {regexp.MustCompile(`- .value \("[A-Za-z0-9 !]{1,}"\)`)},
"value": {regexp.MustCompile(`- .[vV]alue \("[A-Za-z0-9 !]{1,}"\)`)},
"name": {regexp.MustCompile(`- .name \([A-Za-z -]{1,}\)`)},
"topic_name": {regexp.MustCompile(`- .topic_name \([A-Za-z0-9 ]{1,}\)`)},
"next_cursor": {regexp.MustCompile(`- .next_cursor \(\{[A-Za-z0-9 ]{1,}\}\)`)},
Expand Down
Loading

0 comments on commit a7950fa

Please sign in to comment.