Compare commits
3 Commits
master
...
f5ab37c579
Author | SHA1 | Date | |
---|---|---|---|
f5ab37c579 | |||
809f967fb1 | |||
1b5e1ffb95 |
6
.github/workflows/ci.yaml
vendored
6
.github/workflows/ci.yaml
vendored
@ -59,6 +59,9 @@ jobs:
|
|||||||
run: composer update --no-progress --no-interaction --prefer-dist --prefer-lowest
|
run: composer update --no-progress --no-interaction --prefer-dist --prefer-lowest
|
||||||
if: ${{ matrix.dependencies == 'lowest' }}
|
if: ${{ matrix.dependencies == 'lowest' }}
|
||||||
|
|
||||||
|
- name: Install nsq bin
|
||||||
|
run: curl -L https://github.com/nsqio/nsq/releases/download/v1.2.0/nsq-1.2.0.linux-amd64.go1.12.9.tar.gz | tar xz --strip 1
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: vendor/bin/phpunit --coverage-clover=build/coverage-report.xml
|
run: vendor/bin/phpunit --coverage-clover=build/coverage-report.xml
|
||||||
|
|
||||||
@ -197,6 +200,9 @@ jobs:
|
|||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: composer update --no-progress --no-interaction --prefer-dist
|
run: composer update --no-progress --no-interaction --prefer-dist
|
||||||
|
|
||||||
|
- name: Install nsq bin
|
||||||
|
run: curl -L https://github.com/nsqio/nsq/releases/download/v1.2.0/nsq-1.2.0.linux-amd64.go1.12.9.tar.gz | tar xz --strip 1
|
||||||
|
|
||||||
- name: Run script
|
- name: Run script
|
||||||
env:
|
env:
|
||||||
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
|
STRYKER_DASHBOARD_API_KEY: ${{ secrets.STRYKER_DASHBOARD_API_KEY }}
|
||||||
|
11
.gitignore
vendored
11
.gitignore
vendored
@ -4,3 +4,14 @@
|
|||||||
/.php_cs.cache
|
/.php_cs.cache
|
||||||
/.phpunit.result.cache
|
/.phpunit.result.cache
|
||||||
/infection.log
|
/infection.log
|
||||||
|
|
||||||
|
# Nsq
|
||||||
|
bin/nsq_stat
|
||||||
|
bin/nsq_tail
|
||||||
|
bin/nsq_to_file
|
||||||
|
bin/nsq_to_http
|
||||||
|
bin/nsq_to_nsq
|
||||||
|
bin/nsqadmin
|
||||||
|
bin/nsqd
|
||||||
|
bin/nsqlookupd
|
||||||
|
bin/to_nsq
|
||||||
|
0
bin/.gitkeep
Normal file
0
bin/.gitkeep
Normal file
@ -1,39 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
use Nsq\Config\ClientConfig;
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
|
|
||||||
final class NsqTest extends TestCase
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @dataProvider configs
|
|
||||||
*/
|
|
||||||
public function test(ClientConfig $clientConfig): void
|
|
||||||
{
|
|
||||||
self::markTestSkipped('');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Generator<string, array<int, ClientConfig>>
|
|
||||||
*/
|
|
||||||
public function configs(): Generator
|
|
||||||
{
|
|
||||||
yield 'default' => [
|
|
||||||
new ClientConfig(
|
|
||||||
heartbeatInterval: 3000,
|
|
||||||
snappy: false,
|
|
||||||
readTimeout: 1,
|
|
||||||
),
|
|
||||||
];
|
|
||||||
|
|
||||||
yield 'snappy' => [
|
|
||||||
new ClientConfig(
|
|
||||||
heartbeatInterval: 3000,
|
|
||||||
snappy: true,
|
|
||||||
readTimeout: 1,
|
|
||||||
),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
@ -3,12 +3,44 @@
|
|||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
use Amp\Loop;
|
use Amp\Loop;
|
||||||
|
use Amp\Process\Process;
|
||||||
use Nsq\Exception\ServerException;
|
use Nsq\Exception\ServerException;
|
||||||
use Nsq\Producer;
|
use Nsq\Producer;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use function Amp\ByteStream\buffer;
|
||||||
|
use function Amp\Promise\wait;
|
||||||
|
|
||||||
final class ProducerTest extends TestCase
|
final class ProducerTest extends TestCase
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @param array<int, string>|string $body
|
||||||
|
*
|
||||||
|
* @dataProvider data
|
||||||
|
*/
|
||||||
|
public function testPublish(array | string $body, string $expected): void
|
||||||
|
{
|
||||||
|
$process = new Process(
|
||||||
|
sprintf('bin/nsq_tail -topic %s -channel default -nsqd-tcp-address localhost:4150 -n 1', __FUNCTION__),
|
||||||
|
);
|
||||||
|
wait($process->start());
|
||||||
|
|
||||||
|
$producer = Producer::create('tcp://localhost:4150');
|
||||||
|
wait($producer->connect());
|
||||||
|
wait($producer->publish(__FUNCTION__, $body));
|
||||||
|
|
||||||
|
wait($process->join());
|
||||||
|
|
||||||
|
self::assertSame($expected, wait(buffer($process->getStdout())));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Generator<int, array{0: string|array, 1: string}>
|
||||||
|
*/
|
||||||
|
public function data(): Generator
|
||||||
|
{
|
||||||
|
yield ['Test Message One!', 'Test Message One!'.PHP_EOL];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider pubFails
|
* @dataProvider pubFails
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user