Skip to content

Commit cae4158

Browse files
committed
Fix broken tests
After usage of ConnectionState it becomes possible to throw away some internal variables and change internal interfaces, so testing approach needed patching too.
1 parent ee838dc commit cae4158

File tree

6 files changed

+17
-17
lines changed

6 files changed

+17
-17
lines changed

lib/Cro/HTTP2/GeneralParser.pm6

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ my class Stream {
1818
}
1919

2020
role Cro::HTTP2::GeneralParser does Cro::ConnectionState[Cro::HTTP2::ConnectionState] {
21-
has $.ping;
22-
has $.settings;
2321
has $!pseudo-headers;
2422

2523
method transformer(Supply:D $in, Cro::HTTP2::ConnectionState :$connection-state!) {
@@ -104,7 +102,7 @@ role Cro::HTTP2::GeneralParser does Cro::ConnectionState[Cro::HTTP2::ConnectionS
104102
when Cro::HTTP2::Frame::RstStream {
105103
}
106104
when Cro::HTTP2::Frame::Settings {
107-
$!settings.emit: $_;
105+
$connection-state.settings.emit: $_;
108106
}
109107
when Cro::HTTP2::Frame::PushPromise {
110108
my @headers = $decoder.decode-headers(Buf.new: .headers);
@@ -127,7 +125,7 @@ role Cro::HTTP2::GeneralParser does Cro::ConnectionState[Cro::HTTP2::ConnectionS
127125
}
128126
}
129127
when Cro::HTTP2::Frame::Ping {
130-
$!ping.emit: $_;
128+
$connection-state.ping.emit: $_;
131129
}
132130
when Cro::HTTP2::Frame::GoAway {
133131
}

lib/Cro/HTTP2/RequestParser.pm6

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class Cro::HTTP2::RequestParser does Cro::Transform does Cro::HTTP2::GeneralPars
77
method consumes() { Cro::HTTP2::Frame }
88
method produces() { Cro::HTTP::Request }
99

10-
submethod BUILD(:$!settings, :$!ping) {
10+
submethod BUILD() {
1111
$!pseudo-headers = <:method :scheme :authority :path :status>;
1212
}
1313

lib/Cro/HTTP2/ResponseParser.pm6

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class Cro::HTTP2::ResponseParser does Cro::Transform does Cro::HTTP2::GeneralPar
66
method consumes() { Cro::HTTP2::Frame }
77
method produces() { Cro::HTTP::Response }
88

9-
submethod BUILD(:$!settings, :$!ping) {
9+
submethod BUILD() {
1010
$!pseudo-headers = <:status>;
1111
}
1212

t/http2-request-parser.t

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@ my $encoder = HTTP::HPACK::Encoder.new;
88
my ($buf, @headers);
99

1010
sub test(@frames, $count, $desc, @checks, :$fail, :$test-supplies) {
11-
my ($ping, $settings);
1211
my $test-completed = Promise.new;
12+
my $connection-state = Cro::HTTP2::ConnectionState.new;
1313
with $test-supplies {
14-
$ping = Supplier.new;
15-
$settings = Supplier.new;
16-
$ping.Supply.tap: -> $ping {
17-
$test-completed.keep;
18-
$test-supplies.keep;
19-
};
14+
my $ping = $connection-state.ping.Supply;
15+
$ping.tap(
16+
-> $_ {
17+
$test-completed.keep;
18+
$test-supplies.keep;
19+
});
2020
}
21-
my $parser = Cro::HTTP2::RequestParser.new(:$ping);
21+
my $parser = Cro::HTTP2::RequestParser.new;
2222
my $fake-in = Supplier.new;
2323
my $counter = 0;
24-
$parser.transformer($fake-in.Supply).tap:
24+
$parser.transformer($fake-in.Supply, :$connection-state).tap:
2525
-> $request {
2626
for @checks[$counter].kv -> $i, $check {
2727
ok $check($request), "check {$i + 1}";

t/http2-response-parser.t

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ sub test(@frames, $count, $desc, @checks, :$fail) {
1212
my $parser = Cro::HTTP2::ResponseParser.new(:$ping);
1313
my $fake-in = Supplier.new;
1414
my $counter = 0;
15-
$parser.transformer($fake-in.Supply).tap:
15+
my $connection-state = Cro::HTTP2::ConnectionState.new;
16+
$parser.transformer($fake-in.Supply, :$connection-state).tap:
1617
-> $response {
1718
for @checks[$counter].kv -> $i, $check {
1819
ok $check($response), "check {$i + 1}";

t/http2-response-serializer.t

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ sub test($response, $count, $desc, *@checks, :$fail) {
1313
my $serializer = Cro::HTTP2::ResponseSerializer.new;
1414
my $fake-in = Supplier.new;
1515
my $counter = 0;
16-
$serializer.transformer($fake-in.Supply).tap:
16+
my $connection-state = Cro::HTTP2::ConnectionState.new;
17+
$serializer.transformer($fake-in.Supply, :$connection-state).tap:
1718
-> $frame {
1819
for @checks[$counter].kv -> $i, $check {
1920
ok $check($frame), "check {$i + 1}";

0 commit comments

Comments
 (0)