aboutsummaryrefslogtreecommitdiffstats
path: root/hosted-api
diff options
context:
space:
mode:
authorBjørn Christian Seime <bjorncs@verizonmedia.com>2020-06-22 16:58:28 +0200
committerBjørn Christian Seime <bjorncs@verizonmedia.com>2020-06-22 16:58:28 +0200
commit2a9fef2d14bb4735ad59244f1af8a7b6971fd8f8 (patch)
tree49fcecce5641b7a429f60862f628725971dd1559 /hosted-api
parentab8f58e24925b3ae944b7099726372f5726f7cd2 (diff)
Move unit test to same location as class being tested
Diffstat (limited to 'hosted-api')
-rw-r--r--hosted-api/src/test/java/ai/vespa/hosted/api/TestDescriptorTest.java70
1 files changed, 70 insertions, 0 deletions
diff --git a/hosted-api/src/test/java/ai/vespa/hosted/api/TestDescriptorTest.java b/hosted-api/src/test/java/ai/vespa/hosted/api/TestDescriptorTest.java
new file mode 100644
index 00000000000..2676d9d79da
--- /dev/null
+++ b/hosted-api/src/test/java/ai/vespa/hosted/api/TestDescriptorTest.java
@@ -0,0 +1,70 @@
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package ai.vespa.hosted.api;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author mortent
+ */
+public class TestDescriptorTest {
+
+ @Test
+ public void parses_system_test_only () {
+ String testDescriptor = "{\n" +
+ " \"version\": \"1.0\",\n" +
+ " \"configuredTests\": {\n" +
+ " \"systemTests\": [\n" +
+ " \"ai.vespa.test.SystemTest1\",\n" +
+ " \"ai.vespa.test.SystemTest2\"\n" +
+ " ]\n" +
+ " " +
+ "}\n" +
+ "}";
+ var testClassDescriptor = TestDescriptor.fromJsonString(testDescriptor);
+
+ var systemTests = testClassDescriptor.getConfiguredTests(TestDescriptor.TestCategory.systemtest);
+ Assertions.assertIterableEquals(List.of("ai.vespa.test.SystemTest1", "ai.vespa.test.SystemTest2"), systemTests);
+
+ var stagingTests = testClassDescriptor.getConfiguredTests(TestDescriptor.TestCategory.stagingtest);
+ Assertions.assertIterableEquals(Collections.emptyList(), stagingTests);
+
+ var productionTests = testClassDescriptor.getConfiguredTests(TestDescriptor.TestCategory.productiontest);
+ Assertions.assertIterableEquals(Collections.emptyList(), productionTests);
+ }
+
+ @Test
+ public void parsesDescriptorFile() {
+ String testDescriptor = "{\n" +
+ " \"version\": \"1.0\",\n" +
+ " \"configuredTests\": {\n" +
+ " \"systemTests\": [\n" +
+ " \"ai.vespa.test.SystemTest1\",\n" +
+ " \"ai.vespa.test.SystemTest2\"\n" +
+ " ],\n" +
+ " \"stagingTests\": [\n" +
+ " \"ai.vespa.test.StagingTest1\",\n" +
+ " \"ai.vespa.test.StagingTest2\"\n" +
+ " ],\n" +
+ " \"productionTests\": [\n" +
+ " \"ai.vespa.test.ProductionTest1\",\n" +
+ " \"ai.vespa.test.ProductionTest2\"\n" +
+ " ]\n" +
+ " " +
+ "}\n" +
+ "}";
+ var testClassDescriptor = TestDescriptor.fromJsonString(testDescriptor);
+
+ var systemTests = testClassDescriptor.getConfiguredTests(TestDescriptor.TestCategory.systemtest);
+ Assertions.assertIterableEquals(List.of("ai.vespa.test.SystemTest1", "ai.vespa.test.SystemTest2"), systemTests);
+
+ var stagingTests = testClassDescriptor.getConfiguredTests(TestDescriptor.TestCategory.stagingtest);
+ Assertions.assertIterableEquals(List.of("ai.vespa.test.StagingTest1", "ai.vespa.test.StagingTest2"), stagingTests);
+
+ var productionTests = testClassDescriptor.getConfiguredTests(TestDescriptor.TestCategory.productiontest);
+ Assertions.assertIterableEquals(List.of("ai.vespa.test.ProductionTest1", "ai.vespa.test.ProductionTest2"), productionTests);
+ }
+}