Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Commit 3fcfe1b

Browse files
committed
Added test for app_id
1 parent 2a6d91a commit 3fcfe1b

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/Commands/CleanStatisticsTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,34 @@ public function it_can_clean_the_statistics()
4242

4343
$this->assertCount(0, WebSocketsStatisticsEntry::where('created_at', '<', $cutOffDate)->get());
4444
}
45+
46+
/** @test */
47+
public function it_can_clean_the_statistics_for_app_id_only()
48+
{
49+
Collection::times(60)->each(function (int $index) {
50+
WebSocketsStatisticsEntry::create([
51+
'app_id' => 'app_id',
52+
'peak_connection_count' => 1,
53+
'websocket_message_count' => 2,
54+
'api_message_count' => 3,
55+
'created_at' => Carbon::now()->subDays($index)->startOfDay(),
56+
]);
57+
});
58+
59+
Collection::times(60)->each(function (int $index) {
60+
WebSocketsStatisticsEntry::create([
61+
'app_id' => 'app_id2',
62+
'peak_connection_count' => 1,
63+
'websocket_message_count' => 2,
64+
'api_message_count' => 3,
65+
'created_at' => Carbon::now()->subDays($index)->startOfDay(),
66+
]);
67+
});
68+
69+
$this->assertCount(120, WebSocketsStatisticsEntry::all());
70+
71+
Artisan::call('websockets:clean', ['appId' => 'app_id']);
72+
73+
$this->assertCount(91, WebSocketsStatisticsEntry::all());
74+
}
4575
}

0 commit comments

Comments
 (0)