Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: make tests arch-specific #16

Merged
merged 1 commit into from
Jan 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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