diff --git a/.github/workflows/codestyle.yml b/.github/workflows/codestyle.yml index 579023f..4f19856 100644 --- a/.github/workflows/codestyle.yml +++ b/.github/workflows/codestyle.yml @@ -1,8 +1,6 @@ name: codestyle on: pull_request: - paths: - - "!*.md" workflow_dispatch: jobs: code-coverage: diff --git a/tests/RedisSequenceResolverTest.php b/tests/RedisSequenceResolverTest.php index 1e7d75d..b58162f 100644 --- a/tests/RedisSequenceResolverTest.php +++ b/tests/RedisSequenceResolverTest.php @@ -13,6 +13,7 @@ namespace Tests; use Godruoyi\Snowflake\RedisSequenceResolver; +use Godruoyi\Snowflake\Snowflake; use RedisException; class RedisSequenceResolverTest extends TestCase @@ -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)); } }