You've already forked Traefik-Redis-Api
Nothing to see here, move along
This commit is contained in:
@@ -68,6 +68,58 @@ class RedisClientRoutersTest extends Unit
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
|
||||
public function testGetOneHttp(): void
|
||||
{
|
||||
$this->getOneTest(ProtocolEnum::HTTP);
|
||||
}
|
||||
|
||||
public function testGetOneTcp(): void
|
||||
{
|
||||
$this->getOneTest(ProtocolEnum::TCP);
|
||||
}
|
||||
|
||||
public function testGetOneUdp(): void
|
||||
{
|
||||
$this->getOneTest(ProtocolEnum::UDP);
|
||||
}
|
||||
|
||||
private function getOneTest(ProtocolEnum $protocolEnum): void
|
||||
{
|
||||
$commandFactory = Mockery::mock(FactoryInterface::class)
|
||||
->expects('supports')
|
||||
->andReturn(true)
|
||||
->getMock();
|
||||
|
||||
Redis::expects('getCommandFactory')
|
||||
->andReturn($commandFactory);
|
||||
|
||||
Redis::expects('scan')
|
||||
->with(0, ['MATCH' => 'traefik/' . $protocolEnum->getValue() . '/routers/foo/*'])
|
||||
->andReturn([0, [
|
||||
'traefik/' . $protocolEnum->getValue() . '/routers/foo/rule',
|
||||
'traefik/' . $protocolEnum->getValue() . '/routers/foo/service',
|
||||
]]);
|
||||
|
||||
Redis::expects('get')
|
||||
->with('traefik/' . $protocolEnum->getValue() . '/routers/foo/rule')
|
||||
->andReturn('Host(`foo.localhost`)');
|
||||
|
||||
Redis::expects('get')
|
||||
->with('traefik/' . $protocolEnum->getValue() . '/routers/foo/service')
|
||||
->andReturn('foo');
|
||||
|
||||
$routers = RedisClient::getRouter('foo', $protocolEnum);
|
||||
|
||||
$this->assertIsArray($routers);
|
||||
|
||||
$this->assertCount(2, $routers);
|
||||
|
||||
$this->assertEquals([
|
||||
'rule' => 'Host(`foo.localhost`)',
|
||||
'service' => 'foo',
|
||||
], $routers);
|
||||
}
|
||||
|
||||
private function allTest(ProtocolEnum $protocol): void
|
||||
{
|
||||
$commandFactory = Mockery::mock(FactoryInterface::class)
|
||||
|
||||
Reference in New Issue
Block a user