Skip to content

Commit 4f08c11

Browse files
committed
Adjust test
1 parent 0bbcde4 commit 4f08c11

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

src/main/java/io/simplelocalize/cli/command/PurgeCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public PurgeCommand(SimpleLocalizeClient client, Boolean force)
2626
public void invoke() throws IOException, InterruptedException
2727
{
2828
String response = client.fetchProject();
29-
String projectName = JsonPath.parse(response).read("$.name", String.class);
29+
String projectName = JsonPath.parse(response).read("$.data.name", String.class);
3030

3131
boolean isForceUsed = force != null && force;
3232
if (isForceUsed)

src/test/java/io/simplelocalize/cli/SimplelocalizeCliCommandTest.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ void status() throws IOException
219219
@Test
220220
void purge() throws IOException
221221
{
222-
// given & when & then
222+
// given
223223
String path = SimplelocalizeCliCommandTest.class.getClassLoader().getResource("mock-api-responses/fetch-project-empty-hosting-resources.json").getPath();
224224
String content = Files.readString(Path.of(path), StandardCharsets.UTF_8);
225225
mockServer.when(request()
@@ -234,8 +234,27 @@ void purge() throws IOException
234234
.withDelay(TimeUnit.MILLISECONDS, 200)
235235
);
236236

237+
mockServer.when(request()
238+
.withMethod("DELETE")
239+
.withPath("/api/v1/translations/purge")
240+
.withHeader("X-SimpleLocalize-Token", "my-api-key"),
241+
Times.exactly(1))
242+
.respond(
243+
response()
244+
.withStatusCode(200)
245+
.withBody("""
246+
{
247+
"msg": "OK",
248+
"status": 200,
249+
"data": []
250+
}
251+
""")
252+
.withDelay(TimeUnit.MILLISECONDS, 200)
253+
);
254+
237255

238-
sut.status("my-api-key", MOCK_SERVER_BASE_URL);
256+
//when
257+
sut.purge("my-api-key", MOCK_SERVER_BASE_URL, true);
239258

240259
}
241260

0 commit comments

Comments
 (0)