Skip to content

Commit

Permalink
wip: test improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbbreuer committed Mar 14, 2021
1 parent c698d72 commit 72939e4
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 19 deletions.
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
AWS_ACCESS_KEY_ID=xxxxxxx
AWS_SECRET_ACCESS_KEY=xxxxxxx
AWS_DEFAULT_REGION=us-east-1
AWS_MEDIACONVERT_ACCOUNT_URL=https://xxxxxxxxx.mediaconvert.us-east-1.amazonaws.com
AWS_IAM_ARN=arn:aws:iam::xxxxxxx:role/MediaConvert_Default_Role
AWS_QUEUE_ARN=arn:aws:mediaconvert:us-east-1:xxxxxxx:queues/Default
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@
/.scrutinizer.yml export-ignore
/tests export-ignore
/.editorconfig export-ignore
/.env export-ignore
/.env.example export-ignore
4 changes: 2 additions & 2 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@

'settings' => [
'OutputGroups' => [
// first thumbnails for sprite generation
// thumbnail generation
[
'CustomName' => 'Thumbnails',
'Name' => 'File Group',
Expand Down Expand Up @@ -114,7 +114,7 @@
],
],

// third mp4
// optimize-mp4 output setting
[
'CustomName' => 'MP4',
'Name' => 'File Group',
Expand Down
24 changes: 13 additions & 11 deletions tests/MediaConverterTest.php
Original file line number Diff line number Diff line change
@@ -1,42 +1,44 @@
<?php

use Meema\MediaConverter\Facades\MediaConvert;

uses(Meema\MediaConverter\Tests\MediaConverterTestCase::class);

beforeEach(function () {
$this->initializeDotEnv();
$this->initializeSettings();
});

it('it can successfully initialize settings', function () {
it('can successfully initialize settings', function () {
$this->assertTrue(is_array($this->settings));
});

it('it can successfully create a job', function () {
$response = Meema\MediaConverter\Facades\MediaConvert::createJob($this->settings, []);
it('can successfully create a job', function () {
$response = MediaConvert::createJob($this->settings);

$this->assertEquals($response['@metadata']['statusCode'], 201);
});

it('it can successfully get a job', function () {
// Just a fixed Id fetched from aws media convert jobs
it('can successfully get a job', function () {
// just a hardcoded job ID retrieved from one of the AWS MediaConvert jobs
$jobId = '1615614565083-g1cgjm';

$response = Meema\MediaConverter\Facades\MediaConvert::getJob($jobId);
$response = MediaConvert::getJob($jobId);

$this->assertEquals($response['@metadata']['statusCode'], 200);
$this->assertEquals($response['Job']['Id'], $jobId);
});

it('it can successfully cancel a job', function () {
$job = Meema\MediaConverter\Facades\MediaConvert::createJob($this->settings, []);
it('can successfully cancel a job', function () {
$job = MediaConvert::createJob($this->settings, []);

$response = Meema\MediaConverter\Facades\MediaConvert::cancelJob($job['Job']['Id']);
$response = MediaConvert::cancelJob($job['Job']['Id']);

$this->assertEquals($response['@metadata']['statusCode'], 202);
});

it('it can successfully list jobs', function () {
$response = Meema\MediaConverter\Facades\MediaConvert::listJobs([]);
it('can successfully list jobs', function () {
$response = MediaConvert::listJobs([]);

$this->assertEquals($response['@metadata']['statusCode'], 200);
$this->assertTrue(count($response) > 0);
Expand Down
6 changes: 3 additions & 3 deletions tests/MediaConverterTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

class MediaConverterTestCase extends TestCase
{
public $settings = [];
public array $settings = [];

public $sizes = [];
public array $sizes = [];

protected function getPackageProviders($app)
protected function getPackageProviders($app): array
{
return [MediaConverterServiceProvider::class];
}
Expand Down
6 changes: 3 additions & 3 deletions tests/config/job.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"OutputGroupSettings":{
"Type":"FILE_GROUP_SETTINGS",
"FileGroupSettings":{
"Destination":"s3:\/\/meema-stage\/\/thumbnails\/",
"Destination":"s3:\/\/meema-stage\/\/pest-tests\/\/thumbnails\/",
"DestinationSettings":{
"S3Settings":{
"AccessControl":{
Expand Down Expand Up @@ -131,7 +131,7 @@
"OutputGroupSettings":{
"Type":"FILE_GROUP_SETTINGS",
"FileGroupSettings":{
"Destination":"s3:\/\/meema-stage\/\/mp4\/",
"Destination":"s3:\/\/meema-stage\/\/pest-tests\/\/mp4\/",
"DestinationSettings":{
"S3Settings":{
"AccessControl":{
Expand Down Expand Up @@ -162,7 +162,7 @@
"DeblockFilter":"DISABLED",
"DenoiseFilter":"DISABLED",
"TimecodeSource":"EMBEDDED",
"FileInput":"s3:\/\/meema-stage\/test-me.mp4"
"FileInput":"s3:\/\/meema-stage\/pest-tests\/\/test-me.mp4"
}
]
}

0 comments on commit 72939e4

Please sign in to comment.