]> Dogcows Code - chaz/graphql-client/blobdiff - t/lib/MockTransport.pm
add tests and many fixes
[chaz/graphql-client] / t / lib / MockTransport.pm
diff --git a/t/lib/MockTransport.pm b/t/lib/MockTransport.pm
new file mode 100644 (file)
index 0000000..7e4159f
--- /dev/null
@@ -0,0 +1,38 @@
+package MockTransport;
+# ABSTRACT: A backend for testing HTTP::AnyUA
+
+use warnings;
+use strict;
+
+sub new { bless {}, shift }
+
+=method response
+
+    $response = $backend->response;
+    $response = $backend->response($response);
+
+Get and set the response hashref or L<Future> that this backend will always respond with.
+
+=cut
+
+sub response { @_ == 2 ? $_[0]->{response} = pop : $_[0]->{response} }
+
+=method requests
+
+    @requests = $backend->requests;
+
+Get the requests the backend has handled so far.
+
+=cut
+
+sub requests { @{$_[0]->{requests} || []} }
+
+sub execute {
+    my $self = shift;
+
+    push @{$self->{requests} ||= []}, [@_];
+
+    return $self->response;
+}
+
+1;
This page took 0.017624 seconds and 4 git commands to generate.