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