-
Notifications
You must be signed in to change notification settings - Fork 489
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Enabled
--file
and --key-separator
to be used together, fix …
…`--key` handling when producing lines (#3092) closes #3076 The issue also mentions it should be added to the CI. I'm looking into doing that. DISCLAIMER: I didn't test this yet Co-authored-by: Özgür Akkurt <[email protected]>
- Loading branch information
1 parent
23c353c
commit 6263076
Showing
3 changed files
with
130 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#!/usr/bin/env bats | ||
|
||
TEST_HELPER_DIR="$BATS_TEST_DIRNAME/../test_helper" | ||
export TEST_HELPER_DIR | ||
|
||
load "$TEST_HELPER_DIR"/tools_check.bash | ||
load "$TEST_HELPER_DIR"/fluvio_dev.bash | ||
load "$TEST_HELPER_DIR"/bats-support/load.bash | ||
load "$TEST_HELPER_DIR"/bats-assert/load.bash | ||
|
||
setup_file() { | ||
TOPIC_NAME=$(random_string) | ||
export TOPIC_NAME | ||
debug_msg "Topic name: $TOPIC_NAME" | ||
|
||
KEY1=$(random_string) | ||
export KEY1 | ||
KEY2=$(random_string) | ||
export KEY2 | ||
KEY3=$(random_string) | ||
export KEY3 | ||
VAL1=$(random_string) | ||
export VAL1 | ||
VAL2=$(random_string) | ||
export VAL2 | ||
VAL3=$(random_string) | ||
export VAL3 | ||
|
||
SEPARATOR='||' | ||
export SEPARATOR | ||
|
||
MULTI_LINE_FILE_CONTENTS=$KEY1$SEPARATOR$VAL1$'\n'$KEY2$SEPARATOR$VAL2$'\n'$KEY3$SEPARATOR$VAL3 | ||
export MULTI_LINE_FILE_CONTENTS | ||
|
||
MULTI_LINE_FILE_NAME=$(random_string) | ||
export MULTI_LINE_FILE_NAME | ||
|
||
run bash -c 'echo "$MULTI_LINE_FILE_CONTENTS" > "$MULTI_LINE_FILE_NAME"' | ||
} | ||
|
||
teardown_file() { | ||
run timeout 15s "$FLUVIO_BIN" topic delete "$TOPIC_NAME" | ||
run rm $MULTI_LINE_FILE_NAME | ||
} | ||
|
||
# Create topic | ||
@test "Create a topic for file message with separator" { | ||
if [ "$FLUVIO_CLI_RELEASE_CHANNEL" == "stable" ]; then | ||
skip "don't run on stable version" | ||
fi | ||
|
||
debug_msg "topic: $TOPIC_NAME" | ||
run timeout 15s "$FLUVIO_BIN" topic create "$TOPIC_NAME" | ||
assert_success | ||
} | ||
|
||
# Produce message | ||
@test "Produce file message with separator" { | ||
if [ "$FLUVIO_CLI_RELEASE_CHANNEL" == "stable" ]; then | ||
skip "don't run on stable version" | ||
fi | ||
|
||
run bash -c 'timeout 15s "$FLUVIO_BIN" produce --file "$MULTI_LINE_FILE_NAME" --key-separator "$SEPARATOR" "$TOPIC_NAME"' | ||
assert_success | ||
} | ||
|
||
# Consume message and compare message | ||
# Warning: Adding anything extra to the `debug_msg` skews the message comparison | ||
@test "Consume file message with separator" { | ||
if [ "$FLUVIO_CLI_RELEASE_CHANNEL" == "stable" ]; then | ||
skip "don't run on stable version" | ||
fi | ||
|
||
run timeout 15s "$FLUVIO_BIN" consume "$TOPIC_NAME" -B -d -F '{{key}}={{value}}' | ||
|
||
assert_output $KEY1=$VAL1$'\n'$KEY2=$VAL2$'\n'$KEY3=$VAL3 | ||
assert_success | ||
} |