Skip to content

Commit

Permalink
Updating to use the new trampolined promises
Browse files Browse the repository at this point in the history
  • Loading branch information
mtdowling committed Apr 15, 2015
1 parent adebccb commit 1bab6b8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/MiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Aws\Result;
use Aws\Signature\SignatureV4;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Promise;

/**
* @covers Aws\Middleware
Expand All @@ -28,6 +29,7 @@ public function testCanTapIntoHandlerList()
}));
$handler = $list->resolve();
$handler(new Command('foo'), new Request('GET', 'http://exmaple.com'));
Promise\trampoline()->run();
$this->assertCount(2, $called);
$this->assertInstanceOf('Aws\CommandInterface', $called[0]);
$this->assertInstanceOf('Psr\Http\Message\RequestInterface', $called[1]);
Expand All @@ -42,6 +44,7 @@ public function testWrapsWithRetryMiddleware()
}));
$handler = $list->resolve();
$handler(new Command('foo'), new Request('GET', 'http://exmaple.com'));
Promise\trampoline()->run();
$this->assertTrue($called);
}

Expand Down Expand Up @@ -75,6 +78,7 @@ public function testAddsSigner()
$list->append('sign', Middleware::signer($creds, Aws\constantly($signature)));
$handler = $list->resolve();
$handler(new Command('foo'), new Request('GET', 'http://exmaple.com'));
Promise\trampoline()->run();
$this->assertTrue($req->hasHeader('Authorization'));
}

Expand Down Expand Up @@ -153,6 +157,7 @@ public function testExtractsSourceFileIntoBody()
'Key' => 'key',
'SourceFile' => __FILE__
]), new Request('PUT', 'http://foo.com'));
Promise\trampoline()->run();
$this->assertTrue($called);
}

Expand All @@ -166,6 +171,7 @@ public function testAppliesHistory()
$req = new Request('GET', 'http://www.foo.com');
$cmd = new Command('foo');
$handler($cmd, $req);
Promise\trampoline()->run();
$this->assertCount(1, $h);
}
}
2 changes: 2 additions & 0 deletions tests/MockHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Aws\Result;
use Psr\Http\Message\RequestInterface;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Promise;

/**
* @covers Aws\MockHandler
Expand Down Expand Up @@ -89,6 +90,7 @@ function ($reason) use (&$thens) {
$cmd = new Command('foo');
$h($cmd, $request);
$h($cmd, $request);
Promise\trampoline()->run();
$this->assertEquals([$r1, $e], $thens);
}

Expand Down
3 changes: 3 additions & 0 deletions tests/TraceMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use GuzzleHttp\Promise\RejectedPromise;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Response;
use GuzzleHttp\Promise;

/**
* @covers Aws\TraceMiddleware
Expand Down Expand Up @@ -43,6 +44,7 @@ public function testEmitsDebugInfo()
$command = new Command('foo', ['a' => '1', 'b' => '2']);
$request = new Request('GET', 'http://foo.com');
$handler($command, $request);
Promise\trampoline()->run();
$this->assertContains("-> Entering step init, name ''", $str);
$this->assertContains('command was set to array', $str);
$this->assertContains('request was set to array', $str);
Expand Down Expand Up @@ -81,6 +83,7 @@ public function testTracksExceptions()
$command = new Command('foo');
$request = new Request('GET', 'http://foo.com');
$handler($command, $request);
Promise\trampoline()->run();
$this->assertContains('error was set to array', $str);
}

Expand Down

0 comments on commit 1bab6b8

Please sign in to comment.