Skip to content

Commit

Permalink
Fixes for tests working directory
Browse files Browse the repository at this point in the history
  • Loading branch information
Aquerr committed Nov 23, 2024
1 parent 79e2c58 commit 1d9ab43
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 5 deletions.
7 changes: 7 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,13 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<workingDirectory>./target/test-run</workingDirectory>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void onEnvironmentPreparedEvent() throws IOException
createConfigFileIfNotExists();
}

public void saveProperties()
public void saveToFile()
{
try(FileWriter fileWriter = new FileWriter(ASWG_CONFIGURATION_FILE_PATH.toFile(), StandardCharsets.UTF_8);
BufferedWriter bufferedWriter = new BufferedWriter(fileWriter))
Expand All @@ -107,7 +107,7 @@ private void createConfigFileIfNotExists() throws IOException
if (Files.notExists(ASWG_CONFIGURATION_FILE_PATH))
{
Files.createFile(ASWG_CONFIGURATION_FILE_PATH);
saveProperties();
saveToFile();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public Mono<ResponseEntity<Void>> saveGeneralProperties(@RequestBody SaveGeneral
.build());
return Mono.empty();
})
.then(Mono.fromRunnable(this.aswgConfig::saveProperties))
.then(Mono.fromRunnable(this.aswgConfig::saveToFile))
.then(Mono.just(ResponseEntity.ok().build()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ void getGeneralPropertiesShouldTriggerUnauthorizedErrorWhenUserNotAuthorized()
@Test
void saveGeneralPropertiesShouldUpdateServerAndModsDirectoryInASWGConfig()
{
String initialServerDirectory = aswgConfig.getServerDirectoryPath();
String initialModsDirectory = aswgConfig.getModsDirectoryPath();

webTestClient.post()
.uri(API_GENERAL_PROPERTIES_URL)
.header(HttpHeaders.AUTHORIZATION, "Bearer " + jwtService.createJwt("test_user"))
Expand All @@ -72,6 +75,10 @@ void saveGeneralPropertiesShouldUpdateServerAndModsDirectoryInASWGConfig()
verify(generalService).saveGeneralProperties(GeneralProperties.builder()
.maxPlayers(MAX_PLAYERS)
.build());

aswgConfig.setServerDirectoryPath(initialServerDirectory);
aswgConfig.setModsDirectoryPath(initialModsDirectory);
aswgConfig.saveToFile();
}

@Test
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/application-test.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ spring.sql.init.mode=always
spring.liquibase.url=jdbc:h2:mem:aswg;DB_CLOSE_DELAY=-1

wiremock.server.port=${server.port}
aswg.server-directory-path=./target
aswg.server-directory-path=.
aswg.mods-directory-path=mods
aswg.job.file-scanner.installation.enabled=false
aswg.steam.web-api-token=ABC123MYTOKEN
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"serverDirectory": "./target",
"serverDirectory": ".",
"modsDirectory": "mods",
"maxPlayers": 10
}

0 comments on commit 1d9ab43

Please sign in to comment.