@@ -16,8 +16,9 @@ use crate::tester::Tester;
1616
1717// As of now, the following expectations do not require "fn returning()" implementations and hence
1818// no structure is provided for them. Setting of these expectations are built directly into tester.rs:
19- // proxy_log(), proxy_set_tick_period_millis(), proxy_set_buffer_bytes(), proxy_replace_header_map_value(),
20- // proxy_remove_header_map_value(), proxy_add_header_map_value(), proxy_send_local_response(), etc.
19+ // proxy_log(), proxy_set_tick_period_millis(), proxy_set_buffer_bytes(), proxy_set_header_map_pairs,
20+ // proxy_replace_header_map_value(), proxy_remove_header_map_value(), proxy_add_header_map_value(),
21+ // proxy_send_local_response(), etc.
2122
2223pub struct ExpectGetCurrentTimeNanos < ' a > {
2324 tester : & ' a mut Tester ,
@@ -28,7 +29,7 @@ impl<'a> ExpectGetCurrentTimeNanos<'a> {
2829 ExpectGetCurrentTimeNanos { tester : tester }
2930 }
3031
31- pub fn returning ( & mut self , current_time_nanos : u64 ) -> & mut Tester {
32+ pub fn returning ( & mut self , current_time_nanos : Option < u64 > ) -> & mut Tester {
3233 self . tester
3334 . get_expect_handle ( )
3435 . staged
@@ -39,18 +40,18 @@ impl<'a> ExpectGetCurrentTimeNanos<'a> {
3940
4041pub struct ExpectGetBufferBytes < ' a > {
4142 tester : & ' a mut Tester ,
42- buffer_type : i32 ,
43+ buffer_type : Option < i32 > ,
4344}
4445
4546impl < ' a > ExpectGetBufferBytes < ' a > {
46- pub fn expecting ( tester : & ' a mut Tester , buffer_type : i32 ) -> ExpectGetBufferBytes {
47+ pub fn expecting ( tester : & ' a mut Tester , buffer_type : Option < i32 > ) -> ExpectGetBufferBytes {
4748 ExpectGetBufferBytes {
4849 tester : tester,
4950 buffer_type : buffer_type,
5051 }
5152 }
5253
53- pub fn returning ( & mut self , buffer_data : & str ) -> & mut Tester {
54+ pub fn returning ( & mut self , buffer_data : Option < & str > ) -> & mut Tester {
5455 self . tester
5556 . get_expect_handle ( )
5657 . staged
@@ -61,18 +62,18 @@ impl<'a> ExpectGetBufferBytes<'a> {
6162
6263pub struct ExpectGetHeaderMapPairs < ' a > {
6364 tester : & ' a mut Tester ,
64- map_type : i32 ,
65+ map_type : Option < i32 > ,
6566}
6667
6768impl < ' a > ExpectGetHeaderMapPairs < ' a > {
68- pub fn expecting ( tester : & ' a mut Tester , map_type : i32 ) -> ExpectGetHeaderMapPairs {
69+ pub fn expecting ( tester : & ' a mut Tester , map_type : Option < i32 > ) -> ExpectGetHeaderMapPairs {
6970 ExpectGetHeaderMapPairs {
7071 tester : tester,
7172 map_type : map_type,
7273 }
7374 }
7475
75- pub fn returning ( & mut self , header_map_pairs : Vec < ( & str , & str ) > ) -> & mut Tester {
76+ pub fn returning ( & mut self , header_map_pairs : Option < Vec < ( & str , & str ) > > ) -> & mut Tester {
7677 self . tester
7778 . get_expect_handle ( )
7879 . staged
@@ -81,39 +82,17 @@ impl<'a> ExpectGetHeaderMapPairs<'a> {
8182 }
8283}
8384
84- pub struct ExpectSetHeaderMapPairs < ' a > {
85- tester : & ' a mut Tester ,
86- map_type : i32 ,
87- }
88-
89- impl < ' a > ExpectSetHeaderMapPairs < ' a > {
90- pub fn expecting ( tester : & ' a mut Tester , map_type : i32 ) -> ExpectSetHeaderMapPairs {
91- ExpectSetHeaderMapPairs {
92- tester : tester,
93- map_type : map_type,
94- }
95- }
96-
97- pub fn returning ( & mut self , header_map_pairs : Vec < ( & str , & str ) > ) -> & mut Tester {
98- self . tester
99- . get_expect_handle ( )
100- . staged
101- . set_expect_set_header_map_pairs ( self . map_type , header_map_pairs) ;
102- self . tester
103- }
104- }
105-
10685pub struct ExpectGetHeaderMapValue < ' a > {
10786 tester : & ' a mut Tester ,
108- map_type : i32 ,
109- header_map_key : & ' static str ,
87+ map_type : Option < i32 > ,
88+ header_map_key : Option < & ' static str > ,
11089}
11190
11291impl < ' a > ExpectGetHeaderMapValue < ' a > {
11392 pub fn expecting (
11493 tester : & ' a mut Tester ,
115- map_type : i32 ,
116- header_map_key : & ' static str ,
94+ map_type : Option < i32 > ,
95+ header_map_key : Option < & ' static str > ,
11796 ) -> ExpectGetHeaderMapValue < ' a > {
11897 ExpectGetHeaderMapValue {
11998 tester : tester,
@@ -122,7 +101,7 @@ impl<'a> ExpectGetHeaderMapValue<'a> {
122101 }
123102 }
124103
125- pub fn returning ( & mut self , header_map_value : & str ) -> & mut Tester {
104+ pub fn returning ( & mut self , header_map_value : Option < & str > ) -> & mut Tester {
126105 self . tester
127106 . get_expect_handle ( )
128107 . staged
@@ -133,21 +112,21 @@ impl<'a> ExpectGetHeaderMapValue<'a> {
133112
134113pub struct ExpectHttpCall < ' a > {
135114 tester : & ' a mut Tester ,
136- upstream : & ' a str ,
137- headers : Option < Vec < ( & ' a str , & ' a str ) > > ,
115+ upstream : Option < & ' a str > ,
116+ headers : Option < Option < Vec < ( & ' a str , & ' a str ) > > > ,
138117 body : Option < & ' a str > ,
139- trailers : Option < Vec < ( & ' a str , & ' a str ) > > ,
140- timeout : u64 ,
118+ trailers : Option < Option < Vec < ( & ' a str , & ' a str ) > > > ,
119+ timeout : Option < u64 > ,
141120}
142121
143122impl < ' a > ExpectHttpCall < ' a > {
144123 pub fn expecting (
145124 tester : & ' a mut Tester ,
146- upstream : & ' a str ,
147- headers : Vec < ( & ' a str , & ' a str ) > ,
125+ upstream : Option < & ' a str > ,
126+ headers : Option < Vec < ( & ' a str , & ' a str ) > > ,
148127 body : Option < & ' a str > ,
149- trailers : Vec < ( & ' a str , & ' a str ) > ,
150- timeout : u64 ,
128+ trailers : Option < Vec < ( & ' a str , & ' a str ) > > ,
129+ timeout : Option < u64 > ,
151130 ) -> ExpectHttpCall < ' a > {
152131 ExpectHttpCall {
153132 tester : tester,
@@ -159,7 +138,7 @@ impl<'a> ExpectHttpCall<'a> {
159138 }
160139 }
161140
162- pub fn returning ( & mut self , token_id : u32 ) -> & mut Tester {
141+ pub fn returning ( & mut self , token_id : Option < u32 > ) -> & mut Tester {
163142 self . tester . get_expect_handle ( ) . staged . set_expect_http_call (
164143 self . upstream ,
165144 self . headers . take ( ) . unwrap ( ) ,
0 commit comments