Skip to content

Commit ae15dbb

Browse files
committed
Delete all test devices
it can happen where the test device gets added multiple times. this would break the old code as it could not delete the second device.
1 parent a8f5e7c commit ae15dbb

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

LibreNMS/Util/ModuleTestHelper.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
use DeviceCache;
3535
use Illuminate\Database\Eloquent\Model;
3636
use Illuminate\Support\Arr;
37+
use Illuminate\Support\Facades\DB;
3738
use Illuminate\Support\Facades\Log;
3839
use Illuminate\Support\Str;
3940
use LibreNMS\Data\Source\SnmpResponse;
@@ -559,7 +560,8 @@ public function generateTestData(string $snmpSimIp, int $snmpSimPort, bool $noSa
559560

560561
// Remove existing device in case it didn't get removed previously, if we're not running in CI
561562
if (! getenv('CI') && ($existing_device = device_by_name($snmpSimIp)) && isset($existing_device['device_id'])) {
562-
delete_device($existing_device['device_id']);
563+
DB::table('devices')->where('hostname', $snmpSimIp)->delete();
564+
DeviceCache::flush();
563565
}
564566

565567
// Add the test device

0 commit comments

Comments
 (0)