Skip to content

Commit

Permalink
feat: Adds a test section for URL parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Day-OS committed Mar 27, 2024
1 parent 3725001 commit b80b311
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ hub/**

# Development
log.txt
*-logs.txt
*.log

development-config.yml
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ We could write a url_parameter containing the following information:

This would be the ending result:
```md
https://someurl.com?updatecondition=user_id%20%3D%202901
https://someurl.com?updatecondition=user_id+%3D+2901
```


Expand Down
4 changes: 4 additions & 0 deletions crates/http-sink/config-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ http:
endpoint: "https://httpbin.org/post"
http_request_timeout: 1s
http_connect_timeout: 15s
url_parameters:
- record_key: id
url_key: sql_condition
prefix: "user_id = "
3 changes: 3 additions & 0 deletions crates/tiny-http-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ pub struct RequestData {
payload: String,
#[allow(dead_code)]
user_agent: String,
#[allow(dead_code)]
url: String,
}

#[derive(Clone, Debug, Default)]
Expand Down Expand Up @@ -91,6 +93,7 @@ fn main() {
let data = RequestData {
payload: content.clone(),
user_agent: user_agent.map(|h| h.value.to_string()).unwrap_or_default(),
url: request.url().to_string()
};

state.append_payload(data);
Expand Down
19 changes: 19 additions & 0 deletions tests/integration-sends-data-via-post.bats
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,25 @@ teardown() {
kill $MOCK_PID
}


@test "url_parameter" {
echo "Starting consumer on topic $TOPIC"
echo "Using connector $CONNECTOR"
sleep 45

echo "Produce \"{\"id\": 2901, \"name\": \"Luiz Barros Rocha\", \"age\": 26}\" on $TOPIC"
echo "{\"id\": 2901, \"name\": \"Luiz Barros Rocha\", \"age\": 26}" | fluvio produce $TOPIC

echo "Sleep to ensure record is processed"
sleep 25

echo ""

cat ./$LOGGER_FILENAME | grep "url: \"/?condition=user_id+%3D+2901&age=26+years\""
assert_success
}


@test "integration-sends-data-via-post" {
echo "Starting consumer on topic $TOPIC"
echo "Using connector $CONNECTOR"
Expand Down

0 comments on commit b80b311

Please sign in to comment.