Skip to content

Commit 013b500

Browse files
authored
Allow SSE tests to use new config options (#22)
1 parent 7e57ee5 commit 013b500

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
TEMP_TEST_OUTPUT=/tmp/contract-test-service.log
2-
SKIPFLAGS = -skip 'basic parsing' -skip 'HTTP behavior' -skip 'reconnection'
2+
SKIPFLAGS = -skip 'reconnection' -skip 'basic parsing/ID field is ignored if it contains a null' -skip 'basic parsing/last ID persists if not overridden by later event' \
3+
-skip 'HTTP behavior/client follows 301 redirect' -skip 'HTTP behavior/client follows 307 redirect'
4+
35

46
build-contract-tests:
57
@cargo build

contract-tests/src/bin/sse-test-api/main.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@ struct Config {
3232
/// property if the test service has the "headers" capability. Header names can be assumed
3333
/// to all be lowercase.
3434
headers: Option<HashMap<String, String>>,
35+
/// An optional integer specifying the read timeout for the connection, in
36+
/// milliseconds.
37+
read_timeout_ms: Option<u64>,
38+
/// An optional string which should be sent as the Last-Event-Id header in the initial
39+
/// HTTP request. The test harness will only set this property if the test service has the
40+
/// "last-event-id" capability.
41+
last_event_id: Option<String>,
42+
/// A string specifying an HTTP method to use instead of GET. The test harness will only
43+
/// set this property if the test service has the "post" or "report" capability.
44+
method: Option<String>,
45+
/// A string specifying data to be sent in the HTTP request body. The test harness will
46+
/// only set this property if the test service has the "post" or "report" capability.
47+
body: Option<String>,
3548
}
3649

3750
#[derive(Serialize, Debug)]

contract-tests/src/bin/sse-test-api/stream_entity.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,22 @@ impl Inner {
9898
reconnect_options = reconnect_options.delay(Duration::from_millis(delay_ms));
9999
}
100100

101+
if let Some(read_timeout_ms) = config.read_timeout_ms {
102+
client_builder = client_builder.read_timeout(Duration::from_millis(read_timeout_ms));
103+
}
104+
105+
if let Some(last_event_id) = &config.last_event_id {
106+
client_builder = client_builder.last_event_id(last_event_id.clone());
107+
}
108+
109+
if let Some(method) = &config.method {
110+
client_builder = client_builder.method(method.to_string());
111+
}
112+
113+
if let Some(body) = &config.body {
114+
client_builder = client_builder.body(body.to_string());
115+
}
116+
101117
if let Some(headers) = &config.headers {
102118
for (name, value) in headers {
103119
client_builder = match client_builder.header(name, value) {

0 commit comments

Comments
 (0)