Skip to content

Commit

Permalink
chore: remove codestyle workflow filter (#69)
Browse files Browse the repository at this point in the history
* chore: remove codestyle workflow filter

* fix redis test
  • Loading branch information
godruoyi authored Mar 12, 2024
1 parent dec895d commit 79d099d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/codestyle.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: codestyle
on:
pull_request:
paths:
- "!*.md"
workflow_dispatch:
jobs:
code-coverage:
Expand Down
15 changes: 10 additions & 5 deletions tests/RedisSequenceResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
namespace Tests;

use Godruoyi\Snowflake\RedisSequenceResolver;
use Godruoyi\Snowflake\Snowflake;
use RedisException;

class RedisSequenceResolverTest extends TestCase
Expand Down Expand Up @@ -75,15 +76,19 @@ public function test_real_redis(): void
$redis = new \Redis();
$redis->connect($host, $port | 0);

// Sometimes running these tests in parallel on Github may cause unexpected errors,
// so we change to use random here.
$key = (new Snowflake())->getCurrentMillisecond();

$redisResolver = new RedisSequenceResolver($redis);

$this->assertEquals(0, $redisResolver->sequence(1));
$this->assertEquals(1, $redisResolver->sequence(1));
$this->assertEquals(2, $redisResolver->sequence(1));
$this->assertEquals(3, $redisResolver->sequence(1));
$this->assertEquals(0, $redisResolver->sequence($key));
$this->assertEquals(1, $redisResolver->sequence($key));
$this->assertEquals(2, $redisResolver->sequence($key));
$this->assertEquals(3, $redisResolver->sequence($key));

sleep(10);

$this->assertEquals(0, $redisResolver->sequence(1));
$this->assertEquals(0, $redisResolver->sequence($key));
}
}

0 comments on commit 79d099d

Please sign in to comment.