Skip to content

Commit 7adbb1c

Browse files
julienbourdeauaseure
authored andcommitted
chore(travis): Bypass key management tests for community PRs
1 parent 820b0df commit 7adbb1c

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

algoliasearch-tests/src/test/java/com/algolia/search/integration/common/async/AsyncApiKeysTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import static java.util.concurrent.TimeUnit.SECONDS;
44
import static org.assertj.core.api.Assertions.assertThat;
5+
import static org.junit.Assume.assumeTrue;
56

67
import com.algolia.search.AlgoliaObject;
78
import com.algolia.search.AsyncAlgoliaIntegrationTest;
@@ -11,10 +12,23 @@
1112
import java.util.List;
1213
import java.util.concurrent.CompletableFuture;
1314
import javax.annotation.Nonnull;
15+
import org.junit.Before;
1416
import org.junit.Test;
1517

1618
public abstract class AsyncApiKeysTest extends AsyncAlgoliaIntegrationTest {
1719

20+
/**
21+
* If the tests are run on Travis from a pull request of a contributor we need to bypass key
22+
* management tests since they require the Admin API key
23+
*/
24+
@Before
25+
public void skipIfIsCommunity() {
26+
String isCommunity = System.getenv("IS_COMMUNITY");
27+
if (isCommunity != null && !isCommunity.isEmpty()) {
28+
assumeTrue(false);
29+
}
30+
}
31+
1832
private void waitForKeyPresent(AsyncIndex<AlgoliaObject> index, @Nonnull String description)
1933
throws Exception {
2034
for (int i = 0; i < 100; i++) {

algoliasearch-tests/src/test/java/com/algolia/search/integration/common/sync/SyncApiKeysTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.algolia.search.integration.common.sync;
22

33
import static org.assertj.core.api.Assertions.assertThat;
4+
import static org.junit.Assume.assumeTrue;
45

56
import com.algolia.search.AlgoliaObject;
67
import com.algolia.search.Index;
@@ -9,11 +10,24 @@
910
import com.algolia.search.objects.ApiKey;
1011
import java.util.Collections;
1112
import java.util.List;
13+
import org.junit.Before;
1214
import org.junit.Test;
1315

1416
@SuppressWarnings("ConstantConditions")
1517
public abstract class SyncApiKeysTest extends SyncAlgoliaIntegrationTest {
1618

19+
/**
20+
* If the tests are run on Travis from a pull request of a contributor we need to bypass key
21+
* management tests since they require the Admin API key
22+
*/
23+
@Before
24+
public void skipIfIsCommunity() {
25+
String isCommunity = System.getenv("IS_COMMUNITY");
26+
if (isCommunity != null && !isCommunity.isEmpty()) {
27+
assumeTrue(false);
28+
}
29+
}
30+
1731
private void waitForKeyPresent(Index<AlgoliaObject> index, String description)
1832
throws AlgoliaException, InterruptedException {
1933
for (int i = 0; i < 100; i++) {

0 commit comments

Comments
 (0)