Skip to content

Commit d7f23f6

Browse files
committed
Fix WatchJson5 test
1 parent a3c3e64 commit d7f23f6

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

it/src/test/java/com/linecorp/centraldogma/it/WatchTest.java

+12-6
Original file line numberDiff line numberDiff line change
@@ -751,11 +751,15 @@ void repositoryWatcher_errorOnEntryNotFound_watchIsNotWorking() throws Exception
751751
}
752752

753753
private static void revertTestFiles(ClientType clientType) {
754+
revertTestFiles(clientType.client(dogma));
755+
}
756+
757+
private static void revertTestFiles(CentralDogma client) {
754758
final Change<JsonNode> change1 = Change.ofJsonUpsert("/test/test1.json", "[ 1, 2, 3 ]");
755759
final Change<JsonNode> change2 = Change.ofJsonUpsert("/test/test2.json", "{ \"a\": \"apple\" }");
760+
final Change<JsonNode> change3 = Change.ofJsonUpsert("/test/test1.json5", JSON5_CONTENTS);
756761

757-
final List<Change<JsonNode>> changes = Arrays.asList(change1, change2);
758-
final CentralDogma client = clientType.client(dogma);
762+
final List<Change<JsonNode>> changes = Arrays.asList(change1, change2, change3);
759763

760764
if (!client.getPreviewDiffs(dogma.project(), dogma.repo1(), Revision.HEAD, changes)
761765
.join().isEmpty()) {
@@ -765,12 +769,12 @@ private static void revertTestFiles(ClientType clientType) {
765769
.join();
766770
}
767771

768-
final Change<Void> change3 = Change.ofRemoval("/test_not_found/test.json");
772+
final Change<Void> change4 = Change.ofRemoval("/test_not_found/test.json");
769773
final Map<String, EntryType> files = client.listFiles(dogma.project(), dogma.repo1(), Revision.HEAD,
770774
PathPattern.of("/test_not_found/**")).join();
771-
if (files.containsKey(change3.path())) {
775+
if (files.containsKey(change4.path())) {
772776
client.forRepo(dogma.project(), dogma.repo1())
773-
.commit("Remove test files", change3)
777+
.commit("Remove test files", change4)
774778
.push()
775779
.join();
776780
}
@@ -782,6 +786,7 @@ class WatchJson5Test {
782786
@Test
783787
void watchJson5() throws Exception {
784788
final CentralDogma client = dogma.client();
789+
revertTestFiles(client);
785790

786791
final CompletableFuture<Entry<JsonNode>> future =
787792
client.forRepo(dogma.project(), dogma.repo1())
@@ -814,6 +819,7 @@ void watchJson5() throws Exception {
814819
@Test
815820
void watchJson5_notNotifiedIfJsonContentNotChanged() throws JsonParseException {
816821
final CentralDogma client = dogma.client();
822+
revertTestFiles(client);
817823

818824
final CompletableFuture<Entry<JsonNode>> future =
819825
client.forRepo(dogma.project(), dogma.repo1())
@@ -829,7 +835,7 @@ void watchJson5_notNotifiedIfJsonContentNotChanged() throws JsonParseException {
829835
.join();
830836

831837
// Watcher should not be notified since the JSON content is still the same.
832-
assertThatThrownBy(() -> future.get(1000, TimeUnit.MILLISECONDS))
838+
assertThatThrownBy(() -> future.get(500, TimeUnit.MILLISECONDS))
833839
.isInstanceOf(TimeoutException.class);
834840
}
835841
}

0 commit comments

Comments
 (0)