Created
March 9, 2021 16:34
-
-
Save xstefank/ea6abf384b576be65144ea964f0aba68 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/tyr-core/src/test/java/org/jboss/tyr/TestUtils.java b/tyr-core/src/test/java/org/jboss/tyr/TestUtils.java | |
index ab47155..f790417 100644 | |
--- a/tyr-core/src/test/java/org/jboss/tyr/TestUtils.java | |
+++ b/tyr-core/src/test/java/org/jboss/tyr/TestUtils.java | |
@@ -46,6 +46,7 @@ public class TestUtils { | |
public static final JsonObject EMPTY_PAYLOAD = createEmptyJsonPayload(); | |
public static final JsonArray TEST_COMMITS_PAYLOAD = loadJsonArray(JSON_DIR + "/testCommitsPayload.json"); | |
+ public static final JsonArray MULTIPLE_COMMIT_MESSAGES_PAYLOAD = loadJsonArray(JSON_DIR + "/multipleCommitMessagesPayload.json"); | |
public static final FormatYaml FORMAT_CONFIG = loadFormatFromYamlFile(YAML_DIR + "/testTemplate.yaml"); | |
public static final FormatYaml FORMAT_CONFIG_CI = loadFormatFromYamlFile(YAML_DIR + "/testTemplateCI.yaml"); | |
@@ -88,6 +89,15 @@ public class TestUtils { | |
} | |
} | |
+ public static File getFile(String fileName) { | |
+ try { | |
+ String path = TestUtils.class.getClassLoader().getResource(fileName).getFile(); | |
+ return new File(URLDecoder.decode(path, "UTF-8")); | |
+ } catch (UnsupportedEncodingException e) { | |
+ throw new IllegalStateException("Cannot get file " + fileName, e); | |
+ } | |
+ } | |
+ | |
private static JsonObject loadJson(String fileName) { | |
try { | |
return Json.createReader(new FileReader(getFile(fileName))).readObject(); | |
@@ -115,13 +125,4 @@ public class TestUtils { | |
throw new IllegalStateException("Cannot get path of file: " + fileName, e); | |
} | |
} | |
- | |
- private static File getFile(String fileName) { | |
- try { | |
- String path = TestUtils.class.getClassLoader().getResource(fileName).getFile(); | |
- return new File(URLDecoder.decode(path, "UTF-8")); | |
- } catch (UnsupportedEncodingException e) { | |
- throw new IllegalStateException("Cannot get file " + fileName, e); | |
- } | |
- } | |
} | |
diff --git a/tyr-core/src/test/java/org/jboss/tyr/additional/AdditionalResourcesTest.java b/tyr-core/src/test/java/org/jboss/tyr/additional/AdditionalResourcesTest.java | |
index 6e1f591..20ea3d7 100644 | |
--- a/tyr-core/src/test/java/org/jboss/tyr/additional/AdditionalResourcesTest.java | |
+++ b/tyr-core/src/test/java/org/jboss/tyr/additional/AdditionalResourcesTest.java | |
@@ -23,7 +23,6 @@ import org.jboss.tyr.additional.resource.DummyAdditionalCommand; | |
import org.jboss.tyr.check.TemplateChecker; | |
import org.jboss.tyr.whitelist.WhitelistProcessing; | |
import org.junit.jupiter.api.Assertions; | |
-import org.junit.jupiter.api.Disabled; | |
import org.junit.jupiter.api.Test; | |
import javax.inject.Inject; | |
@@ -58,10 +57,8 @@ public class AdditionalResourcesTest { | |
TemplateChecker templateChecker; | |
@Test | |
- @Disabled("templateChecker.init(TestUtils.FORMAT_CONFIG)") | |
public void additionalChecksInvokedTest() throws InvalidPayloadException { | |
DummyAdditionalCheck.clearCounter(); // incremented by different test checking the valid PR check invocation | |
-// templateChecker.init(TestUtils.FORMAT_CONFIG); | |
String result = templateChecker.checkPR(TestUtils.TEST_PAYLOAD); | |
@@ -80,32 +77,4 @@ public class AdditionalResourcesTest { | |
Assertions.assertTrue(DummyAdditionalCommand.isTriggered()); | |
} | |
- | |
- | |
- @Test | |
- @Disabled("Quarkus support for different config values,templateChecker.init(TestUtils.FORMAT_CONFIG)") | |
- public void invalidPathAdditionalResourcesTest() throws InvalidPayloadException { | |
-// templateChecker.init(TestUtils.FORMAT_CONFIG); | |
- whitelistProcessing.init(TestUtils.FORMAT_CONFIG); | |
- | |
- // should not fail, logs warning | |
- String result = templateChecker.checkPR(TestUtils.TEST_PAYLOAD); | |
- whitelistProcessing.processPRComment(TestUtils.ISSUE_PAYLOAD); | |
- | |
- Assertions.assertTrue(result.isEmpty()); | |
- Assertions.assertFalse(DummyAdditionalCommand.isTriggered()); | |
- } | |
- | |
- @Test | |
- @Disabled("Quarkus support for different config values,templateChecker.init(TestUtils.FORMAT_CONFIG)") | |
- public void emptyAdditionalResourcesPropertyTest() throws InvalidPayloadException { | |
-// templateChecker.init(TestUtils.FORMAT_CONFIG); | |
-// whitelistProcessing.init(TestUtils.FORMAT_CONFIG); | |
- | |
- String result = templateChecker.checkPR(TestUtils.TEST_PAYLOAD); | |
- whitelistProcessing.processPRComment(TestUtils.ISSUE_PAYLOAD); | |
- | |
- Assertions.assertTrue(result.isEmpty()); | |
- Assertions.assertFalse(DummyAdditionalCommand.isTriggered()); | |
- } | |
} | |
diff --git a/tyr-core/src/test/java/org/jboss/tyr/check/CommitMessagesCheckTest.java b/tyr-core/src/test/java/org/jboss/tyr/check/CommitMessagesCheckTest.java | |
index 2c36c50..e2eb53c 100644 | |
--- a/tyr-core/src/test/java/org/jboss/tyr/check/CommitMessagesCheckTest.java | |
+++ b/tyr-core/src/test/java/org/jboss/tyr/check/CommitMessagesCheckTest.java | |
@@ -21,7 +21,6 @@ import org.jboss.tyr.TestUtils; | |
import org.jboss.tyr.model.yaml.RegexDefinition; | |
import org.junit.jupiter.api.Assertions; | |
import org.junit.jupiter.api.BeforeEach; | |
-import org.junit.jupiter.api.Disabled; | |
import org.junit.jupiter.api.Test; | |
import javax.inject.Inject; | |
@@ -77,15 +76,4 @@ public class CommitMessagesCheckTest { | |
Assertions.assertEquals(CommitMessagesCheck.DEFAULT_MESSAGE, commitMessagesCheck.check(TestUtils.TEST_PAYLOAD), "Unexpected message returned"); | |
} | |
- | |
- @Test | |
- @Disabled("multiple mocks support in quarkus (1.4 or 1.3.x)") | |
- public void testMultipleCommitMessages() throws InvalidPayloadException { | |
-// PowerMockito.stub(method(GitHubAPI.class, TestUtils.GET_JSON_WITH_COMMITS, JsonObject.class)).toReturn(TestUtils.MULTIPLE_COMMIT_MESSAGES_PAYLOAD); | |
- | |
- commitRegexDefinition.setPattern(Pattern.compile("Test commit")); | |
- commitMessagesCheck.setRegex(commitRegexDefinition); | |
- | |
- Assertions.assertNull(commitMessagesCheck.check(TestUtils.TEST_PAYLOAD)); | |
- } | |
} | |
diff --git a/tyr-core/src/test/java/org/jboss/tyr/check/TemplateCheckerTest.java b/tyr-core/src/test/java/org/jboss/tyr/check/TemplateCheckerTest.java | |
index ccad01f..6edfe70 100644 | |
--- a/tyr-core/src/test/java/org/jboss/tyr/check/TemplateCheckerTest.java | |
+++ b/tyr-core/src/test/java/org/jboss/tyr/check/TemplateCheckerTest.java | |
@@ -18,9 +18,7 @@ package org.jboss.tyr.check; | |
import io.quarkus.test.junit.QuarkusTest; | |
import org.jboss.tyr.InvalidPayloadException; | |
import org.jboss.tyr.TestUtils; | |
-import org.jboss.tyr.model.yaml.FormatYaml; | |
import org.junit.jupiter.api.Assertions; | |
-import org.junit.jupiter.api.Disabled; | |
import org.junit.jupiter.api.Test; | |
import javax.inject.Inject; | |
@@ -32,24 +30,8 @@ public class TemplateCheckerTest { | |
TemplateChecker templateChecker; | |
@Test | |
- @Disabled("templateChecker.init(TestUtils.FORMAT_CONFIG_CI)") | |
public void testValidTemplateConfig() throws InvalidPayloadException { | |
-// templateChecker.init(TestUtils.FORMAT_CONFIG_CI); | |
Assertions.assertEquals("Dummy check failure", templateChecker.checkPR(TestUtils.TEST_PAYLOAD), | |
"Valid PR should only fail with included additional check"); | |
} | |
- | |
- @Test | |
- @Disabled("templateChecker.init(null)") | |
- public void testNullConfigParameter() { | |
-// Assertions.assertThrows(IllegalArgumentException.class, () -> templateChecker.init(null)); | |
- } | |
- | |
- @Test | |
- @Disabled("templateChecker.init(testConfig)") | |
- public void testNullFormatParameter() { | |
- FormatYaml testConfig = new FormatYaml(); | |
- testConfig.setFormat(null); | |
-// Assertions.assertThrows(IllegalArgumentException.class, () -> templateChecker.init(testConfig)); | |
- } | |
} | |
diff --git a/tyr-core/src/test/java/org/jboss/tyr/config/PushStatusFalseTest.java b/tyr-core/src/test/java/org/jboss/tyr/config/PushStatusFalseTest.java | |
index 59bfb12..103eaf1 100644 | |
--- a/tyr-core/src/test/java/org/jboss/tyr/config/PushStatusFalseTest.java | |
+++ b/tyr-core/src/test/java/org/jboss/tyr/config/PushStatusFalseTest.java | |
@@ -1,4 +1,4 @@ | |
-package org.jboss.tyr.config.pushstatus; | |
+package org.jboss.tyr.config; | |
import io.quarkus.test.junit.QuarkusTest; | |
import io.quarkus.test.junit.QuarkusTestProfile; | |
@@ -20,8 +20,8 @@ import static org.jboss.tyr.TestUtils.YAML_DIR; | |
import static org.mockito.ArgumentMatchers.isA; | |
@QuarkusTest | |
-@TestProfile(TemplateCheckPushStatusTest.Profile.class) | |
-public class TemplateCheckPushStatusTest { | |
+@TestProfile(PushStatusFalseTest.Profile.class) | |
+public class PushStatusFalseTest { | |
public static final class Profile implements QuarkusTestProfile { | |
@Override | |
diff --git a/tyr-core/src/test/java/org/jboss/tyr/config/pushstatus/PushStatusFalseTestProfile.java b/tyr-core/src/test/java/org/jboss/tyr/config/pushstatus/PushStatusFalseTestProfile.java | |
deleted file mode 100644 | |
index 674d4bd..0000000 | |
--- a/tyr-core/src/test/java/org/jboss/tyr/config/pushstatus/PushStatusFalseTestProfile.java | |
+++ /dev/null | |
@@ -1,13 +0,0 @@ | |
-package org.jboss.tyr.config.pushstatus; | |
- | |
-import io.quarkus.test.junit.QuarkusTestProfile; | |
- | |
-import java.util.Map; | |
- | |
-public class PushStatusFalseTestProfile implements QuarkusTestProfile { | |
- | |
- @Override | |
- public Map<String, String> getConfigOverrides() { | |
- return Map.of("tyr.github.status.push", "false"); | |
- } | |
-} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment