Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-hensley committed Mar 27, 2024
1 parent d9eb9e5 commit 96219c3
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions tests/Unit/SDK/Resource/Detectors/HostTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,22 @@ public function test_host_get_resource(): void
$this->assertSame(ResourceAttributes::SCHEMA_URL, $resource->getSchemaUrl());
$this->assertIsString($resource->getAttributes()->get(ResourceAttributes::HOST_NAME));
$this->assertIsString($resource->getAttributes()->get(ResourceAttributes::HOST_ARCH));
$this->assertTrue($resource->getAttributes()->has(ResourceAttributes::HOST_ID));
}

/**
* @dataProvider hostIdData
*/
public function test_host_id_filesystem(string $os, array $files, string $expectedId): void
public function test_host_id_filesystem(string $os, array $files, ?string $expectedId): void
{
$root = vfsStream::setup('/', null, $files);
$resouceDetector = new Detectors\Host($root->url(), $os);
$resource = $resouceDetector->getResource();

if ($expectedId === null) {
$this->assertFalse($resource->getAttributes()->has(ResourceAttributes::HOST_ID));
return;
}

$hostId = $resource->getAttributes()->get(ResourceAttributes::HOST_ID);
$this->assertIsString($hostId);
$this->assertSame($expectedId, $hostId);
Expand Down Expand Up @@ -61,12 +66,12 @@ public static function hostIdData(): array
];

return [
['Linux', [], ''],
['Linux', [], null],
['Linux', $etc_machineid, '1234567890'],
['Linux', array_merge($etc_machineid, $varLibDbus), '1234567890'],
['Linux', $etc_machineid, '1234567890'],
['OpenBSD', [], ''],
['OpenBSD', $etc_hostid, '1234567890'],
['BSD', [], null],
['BSD', $etc_hostid, '1234567890'],
];
}
}

0 comments on commit 96219c3

Please sign in to comment.