Skip to content

Commit 87e2ad5

Browse files
committed
Adjust test
1 parent 7337584 commit 87e2ad5

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

src/test/java/io/simplelocalize/cli/command/PublishHostingCommandTest.java

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class PublishHostingCommandTest
3333

3434

3535
@Test
36-
void invoke() throws Exception
36+
void invokeWhenPassedDefaultEnvironmentKeyWithoutUnderscore() throws Exception
3737
{
3838
//given
3939
List<ILoggingEvent> logEventList = TestLogEventFactory.createAndGetLogEventList(sut.getClass());
@@ -48,11 +48,36 @@ void invoke() throws Exception
4848
sut.invoke();
4949

5050
//then
51-
Mockito.verify(client).publish("latest");
51+
Mockito.verify(client).publish("_latest");
52+
53+
assertThat(logEventList.get(0).getFormattedMessage()).isEqualTo("Project name: My project");
54+
assertThat(logEventList.get(1).getFormattedMessage()).isEqualTo("Project token: dev-e7c0b7686c7b45fea4450a4c4a83c7ff");
55+
assertThat(logEventList.get(2).getFormattedMessage()).isEqualTo("Environment: _latest");
56+
assertThat(logEventList.get(3).getFormattedMessage()).isEqualTo("Publishing translations...");
57+
assertThat(logEventList.get(4).getFormattedMessage()).isEqualTo("Translations published");
58+
}
59+
60+
@Test
61+
void invoke() throws Exception
62+
{
63+
//given
64+
List<ILoggingEvent> logEventList = TestLogEventFactory.createAndGetLogEventList(sut.getClass());
65+
66+
String path = StatusCommandTest.class.getClassLoader().getResource("mock-api-responses/fetch-project.json").getPath();
67+
String content = Files.readString(Path.of(path), StandardCharsets.UTF_8);
68+
Mockito.when(client.fetchProject()).thenReturn(content);
69+
70+
Mockito.when(configuration.getEnvironment()).thenReturn("_latest");
71+
72+
//when
73+
sut.invoke();
74+
75+
//then
76+
Mockito.verify(client).publish("_latest");
5277

5378
assertThat(logEventList.get(0).getFormattedMessage()).isEqualTo("Project name: My project");
5479
assertThat(logEventList.get(1).getFormattedMessage()).isEqualTo("Project token: dev-e7c0b7686c7b45fea4450a4c4a83c7ff");
55-
assertThat(logEventList.get(2).getFormattedMessage()).isEqualTo("Environment: latest");
80+
assertThat(logEventList.get(2).getFormattedMessage()).isEqualTo("Environment: _latest");
5681
assertThat(logEventList.get(3).getFormattedMessage()).isEqualTo("Publishing translations...");
5782
assertThat(logEventList.get(4).getFormattedMessage()).isEqualTo("Translations published");
5883
}

0 commit comments

Comments
 (0)