Skip to content

Commit

Permalink
changed pipe
Browse files Browse the repository at this point in the history
  • Loading branch information
ytake committed Jul 3, 2020
1 parent 9bf0f82 commit 22d6db0
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 30 deletions.
13 changes: 7 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,17 @@
"hhvm/hsl": "^4.0",
"hhvm/hsl-experimental": "^4.50",
"hhvm/hhvm-autoload": "^3.0",
"ytake/hungrr": "^0.12",
"ytake/hhypermedia": "^0.6.0",
"ytake/hungrr": "^0.13.2",
"ytake/hhypermedia": "^0.6.1",
"nazg/glue": "^1.5",
"nazg/heredity": "^1.12",
"nazg/hcache": "^0.6",
"nazg/heredity": "^1.12.1",
"nazg/hcache": "^0.6.1",
"nazg/http-server-request-handler": "^0.6.0",
"nazg/http-executor": "^0.12",
"nazg/http-executor": "^0.12.1",
"facebook/hack-router": "^0.19.6",
"facebook/hh-clilib": "^2.5.0",
"facebook/hack-http-request-response-interfaces": "^0.3",
"hack-logging/hack-logging": "^0.7.0"
"hack-logging/hack-logging": "^0.7.1"
},
"require-dev": {
"facebook/fbexpect": "^2.6.1",
Expand Down
2 changes: 0 additions & 2 deletions src/Foundation/Command/ApplicationCacheClear.hack
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@ final class ApplicationCacheClear extends CliApplication {
$stdout = $this->getStdout();
if($cache->flushAll()) {
await $stdout->writeAsync("Cache Clear");
await $stdout->flushAsync();
return 0;
}
await $stdout->writeAsync("[ERROR] Failed to clear cache.");
await $stdout->flushAsync();
return 1;
}

Expand Down
1 change: 0 additions & 1 deletion src/Foundation/Command/ContainerCacheClear.hack
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ final class ContainerCacheClear extends CliApplication {
apc_delete($config->getContainerCacheKeyname());
$stdout = $this->getStdout();
await $stdout->writeAsync("Deleted Container Cache");
await $stdout->flushAsync();
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Logger/LoggerProvider.hack
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ final class LoggerProvider implements ProviderInterface<Logger> {
$config = $container->get(ApplicationConfig::class);
$logConfig = $config->getLogConfig();
return new Logger($logConfig['logname'], vec[
new FilesystemHandler(File\open_write_only_nd($logConfig['logfile']))
new FilesystemHandler(File\open_write_only($logConfig['logfile']))
]);
}
}
10 changes: 5 additions & 5 deletions tests/ApplicationTest.hack
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@ use function Facebook\FBExpect\expect;
final class ApplicationTest extends HackTest {

public function testShouldReturnApplicationInstance(): void {
list($read, $write) = IO\pipe_nd();
list($read, $write) = IO\pipe();
$container = new Container(new DependencyFactory());
$app = new Foundation\Application($container, $read, $write);
expect($app)->toBeInstanceOf(Foundation\Application::class);
}

public function testShouldApplyApplication(): void {
list($read, $write) = IO\pipe_nd();
list($read, $write) = IO\pipe();
$container = new Container(new DependencyFactory());
$app = new Foundation\Application($container, $read, $write);
$app->build(new Foundation\ApplicationConfig());
expect($app)->toBeInstanceOf(Foundation\Application::class);
}

public function testApplicationRunThrowException(): void {
list($read, $write) = IO\pipe_nd();
list($read, $write) = IO\pipe();
$container = new Container(new DependencyFactory());
$app = new Foundation\Application($container, $read, $write);
$app->build(new Foundation\ApplicationConfig());
Expand All @@ -33,9 +33,9 @@ final class ApplicationTest extends HackTest {
}

public async function testShouldReturnServerResponseCaseFoundRoute(): Awaitable<void> {
list($read, $write) = IO\pipe_nd();
list($read, $write) = IO\pipe();
await $write->writeAsync(json_encode(dict[]));
await $write->closeAsync();
$write->close();
$container = new Container(new DependencyFactory());
$app = new Foundation\Application($container, $read, $write);
$config = new Foundation\ApplicationConfig();
Expand Down
6 changes: 3 additions & 3 deletions tests/Exception/ExceptionHandlerTest.hack
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ final class ExceptionHandlerTest extends HackTest {

public function testShouldReturnExceptionHandlerInterface(): void {
$container = new Container(new DependencyFactory());
list($read, $write) = IO\pipe_nd();
list($read, $write) = IO\pipe();
$container->bind(ExceptionHandleInterface::class)
->provider(new ExceptionHandlerProvider($read, $write, new Emitter\SapiEmitter()));
\HH\Asio\join($container->lockAsync());
Expand All @@ -22,7 +22,7 @@ final class ExceptionHandlerTest extends HackTest {
}

public function testFunctionalExceptionRegister(): void {
list($read, $write) = IO\pipe_nd();
list($read, $write) = IO\pipe();
$e = new ExceptionHandler($read, $write, new Emitter\SapiEmitter());
$register = new ExceptionRegister($e);
$register->register();
Expand All @@ -39,7 +39,7 @@ final class ExceptionHandlerTest extends HackTest {
}

public function testFunctionalThrowNotFoundHttpException(): void {
list($read, $write) = IO\pipe_nd();
list($read, $write) = IO\pipe();
$e = new ExceptionHandler($read, $write, new Emitter\SapiEmitter());
$register = new ExceptionRegister($e);
$register->register();
Expand Down
11 changes: 5 additions & 6 deletions tests/Http/VndErrorResponseTest.hack
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,36 @@ use function Facebook\FBExpect\expect;
final class VndErrorResponseTest extends HackTest {

public async function testShouldBe(): Awaitable<void> {
list($read, $write) = IO\pipe_nd();
list($read, $write) = IO\pipe();
$r = new VndErrorResponse($write);
await $write->writeAsync(\json_encode(dict[]));
await $write->closeAsync();
$write->close();
expect($r->getStatusCode())->toBeSame(500);
expect($r->getProtocolVersion())->toBeSame('1.1');
expect($r->getReasonPhrase())->toBeSame('Internal Server Error');
expect($r->getHeaders())->toBeSame(dict[
'content-type' => vec['application/vnd.error+json'],
]);
await $r->getBody()->flushAsync();
$re = await $read->readAsync();
expect($re)->toBeSame('{}');
}

public async function testShouldReturnJsonBody(): Awaitable<void> {
list($read, $write) = IO\pipe_nd();
list($read, $write) = IO\pipe();
await $write->writeAsync(\json_encode(dict[
'testing' => dict[
'HHVM' => 'Hack',
]
]));
await $write->closeAsync();
$write->close();
$r = new VndErrorResponse($write, StatusCode::FORBIDDEN);
expect($r->getStatusCode())->toBeSame(403);
expect($r->getProtocolVersion())->toBeSame('1.1');
expect($r->getReasonPhrase())->toBeSame('Forbidden');
expect($r->getHeaders())->toBeSame(dict[
'content-type' => vec['application/vnd.error+json'],
]);
await $r->getBody()->flushAsync();
$r->getBody();
$re = await $read->readAsync();
expect($re)->toBeSame('{"testing":{"HHVM":"Hack"}}');
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Middleware/LogExceptionMiddlewareTest.hack
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ final class LogExceptionMiddlewareTest extends HackTest {

public function testShouldPutTestingLog(): void {
$filename = __DIR__ . '/../storages/testing.log';
list($read, $write) = IO\pipe_nd();
list($read, $write) = IO\pipe();
$heredity = new Middleware\Dispatcher(
new AsyncMiddlewareStack(
vec[
Expand Down
2 changes: 1 addition & 1 deletion tests/Middleware/SimpleCorsMiddlewareTest.hack
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class SimpleCorsMiddlewareTest extends HackTest {

public async function testShouldReturnCorsHeader(): Awaitable<void> {
$filename = __DIR__ . '/../storages/testing.log';
list($read, $write) = IO\pipe_nd();
list($read, $write) = IO\pipe();
$heredity = new Middleware\Dispatcher(
new AsyncMiddlewareStack(
vec[
Expand Down
4 changes: 2 additions & 2 deletions tests/Routing/RouterTest.hack
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ final class RouterTest extends HackTest {
}

public function testShouldDetectRouteByRequest(): void {
list($read, $_) = IO\pipe_nd();
list($read, $_) = IO\pipe();
$request = ServerRequestFactory::fromGlobals($read, dict[
'REQUEST_METHOD' => 'GET',
'REQUEST_URI' => '/testing?param=testing'
Expand All @@ -76,7 +76,7 @@ final class RouterTest extends HackTest {
}

public function testShouldNotFoundRouteByRequest(): void {
list($read, $_) = IO\pipe_nd();
list($read, $_) = IO\pipe();
$request = ServerRequestFactory::fromGlobals($read, dict[
'REQUEST_METHOD' => 'GET',
'REQUEST_URI' => '/testing'
Expand Down
4 changes: 2 additions & 2 deletions tests/Validation/ValidatorTest.hack
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ValidatorTest extends HackTest {
}

public function testShouldThrowTypeException(): void {
list($read, $_) = IO\pipe_nd();
list($read, $_) = IO\pipe();
$v = new MockStructureValidateFalied();
$request = ServerRequestFactory::fromGlobals(
$read,
Expand All @@ -34,7 +34,7 @@ class ValidatorTest extends HackTest {
}

public function testShouldThrow(): void {
list($read, $_) = IO\pipe_nd();
list($read, $_) = IO\pipe();
$v = new MockStructureValidateSuccess();
$request = ServerRequestFactory::fromGlobals(
$read,
Expand Down

0 comments on commit 22d6db0

Please sign in to comment.