Skip to content

Commit

Permalink
test: make tests arch-specific (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
metacosm committed Jan 17, 2024
1 parent a69f550 commit 51fa3ba
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion server/src/test/java/io/github/metacosm/PowerResourceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import io.github.metacosm.power.SensorMetadata;
import io.quarkus.test.junit.QuarkusTest;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
import org.junit.jupiter.api.condition.EnabledOnOs;
import org.junit.jupiter.api.condition.OS;

Expand All @@ -25,7 +26,8 @@ public void testPowerEndpoint() {

@Test
@EnabledOnOs(OS.MAC)
public void testMacOSMetadataEndpoint() {
@EnabledIfSystemProperty(named = "os.arch", matches = "aarch64")
public void testMacOSAppleSiliconMetadataEndpoint() {
final var metadata = given()
.when().get("/power/metadata")
.then()
Expand All @@ -48,6 +50,31 @@ public void testMacOSMetadataEndpoint() {
assertFalse(cpuShare.isAttributed());
}

@Test
@EnabledOnOs(OS.MAC)
@EnabledIfSystemProperty(named = "os.arch", matches = "x86_64")
public void testMacOSIntelMetadataEndpoint() {
final var metadata = given()
.when().get("/power/metadata")
.then()
.statusCode(200)
.extract().body().as(SensorMetadata.class);
assertEquals(2, metadata.componentCardinality());
assertTrue(metadata.documentation().contains("powermetrics"));
assertTrue(metadata.components().keySet().containsAll(Set.of("Package", "cpuShare")));

final var cpu = metadata.metadataFor("Package");
assertEquals(0, cpu.index());
assertEquals("W", cpu.unit());
assertTrue(cpu.isAttributed());

final var cpuShare = metadata.metadataFor("cpuShare");
assertEquals(3, cpuShare.index());
assertEquals("cpuShare", cpuShare.name());
assertEquals("decimal percentage", cpuShare.unit());
assertFalse(cpuShare.isAttributed());
}

@Test
@EnabledOnOs(OS.LINUX)
public void testLinuxMetadataEndpoint() {
Expand Down

0 comments on commit 51fa3ba

Please sign in to comment.