Skip to content

Commit

Permalink
Improving test coverage of middleware application with the Glacier cl…
Browse files Browse the repository at this point in the history
…ient.
  • Loading branch information
jeremeamia committed May 12, 2015
1 parent 22587bd commit 91e3181
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
21 changes: 10 additions & 11 deletions tests/Glacier/GlacierClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,30 @@ class GlacierClientTest extends \PHPUnit_Framework_TestCase
{
use UsesServiceTrait;

public function testAddsRequiredParamsAndHeadersAutomatically()
public function testAppliesAllMiddleware()
{
$client = new GlacierClient([
'service' => 'glacier',
'region' => 'us-west-2',
'version' => 'latest',
'http_handler' => function ($req, $opt) use (&$request) {
$request = $req;
return new Response(200);
}
'version' => 'latest'
]);

$command = $client->getCommand('UploadArchive', [
'vaultName' => 'foo',
'body' => 'foo',
'vaultName' => 'foo',
'sourceFile' => __DIR__ . '/test-content.txt',
]);
$client->execute($command);
$request = \Aws\serialize($command);

// Adds default accountId and the API version header.
// Added default accountId and the API version header.
$this->assertEquals('-', $command['accountId']);
$this->assertEquals(
$client->getApi()->getMetadata('apiVersion'),
$request->getHeaderLine('x-amz-glacier-version')
);

// Added Content-Type and Body
$this->assertEquals('foo', $command['body']);
$this->assertEquals('text/plain', $request->getHeaderLine('Content-Type'));

// Added the tree and content hashes.
$hash = hash('sha256', 'foo');
$this->assertEquals($hash, $request->getHeaderLine('x-amz-content-sha256'));
Expand Down
1 change: 1 addition & 0 deletions tests/Glacier/test-content.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
foo

0 comments on commit 91e3181

Please sign in to comment.