Give the importer test a fresh profile every run

The test home under target/ outlives a run, so the identity the first
run imported made every later run fail. The test now points AppDirs at
a temporary directory of its own, which also works when another test
resolved the profile first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-25 10:27:11 +00:00
parent f871a88bce
commit ba5de5a8a8

View File

@@ -1,15 +1,17 @@
package com.ts3client.teamspeak;
import com.ts3client.config.AppDirs;
import com.ts3client.config.Bookmark;
import com.ts3client.config.Bookmarks;
import com.ts3client.config.IdentityEntry;
import com.ts3client.config.IdentityStore;
import com.ts3client.config.Settings;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -18,10 +20,15 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
class TeamSpeakImporterTest {
/** The stores resolve {@code ~/.ts3jclient} once, so point them at scratch space before they load. */
@BeforeAll
static void isolateHome() throws Exception {
System.setProperty("user.home", Files.createTempDirectory("ts3j-import").toString());
/** Each test starts from an empty profile; the shared test home keeps identities from earlier runs. */
@BeforeEach
void freshProfile(@TempDir Path dir) {
AppDirs.init(dir.resolve("profile").toFile(), dir.resolve("chats"));
}
@AfterEach
void defaultProfile() {
AppDirs.init(null, null);
}
@Test