mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IJPL-221005 drop tempDir hack from tests
GitOrigin-RevId: 6a202561c84d5a993f16d9bb8d4560a305e3df36
This commit is contained in:
committed by
intellij-monorepo-bot
parent
51f3a65546
commit
a86582d0b4
+13
-27
@@ -5,10 +5,8 @@ import com.intellij.ide.startup.StartupActionScriptManager
|
||||
import com.intellij.openapi.application.PathManager
|
||||
import com.intellij.testFramework.PlatformTestUtil
|
||||
import com.intellij.testFramework.rules.TempDirectory
|
||||
import com.intellij.testFramework.utils.io.deleteRecursively
|
||||
import com.intellij.util.io.Compressor
|
||||
import com.intellij.util.io.createDirectories
|
||||
import com.intellij.util.io.createParentDirectories
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.assertj.core.api.Assertions.assertThatCode
|
||||
import org.junit.After
|
||||
@@ -151,11 +149,10 @@ class StartupActionScriptManagerTest {
|
||||
assertThat(scriptFile).doesNotExist()
|
||||
}
|
||||
|
||||
@Test fun `executing marketplace commands only`() {
|
||||
val tempDir = Files.createTempDirectory("test") // tempDir from class has 'marketplace' in path due to test name
|
||||
val marketplaceSource = tempDir.resolve("marketplace/plugin.zip").createParentDirectories()
|
||||
@Test fun `executing MP commands only`() {
|
||||
val marketplaceSource = tempDir.newFileNio("marketplace/plugin.zip")
|
||||
Compressor.Zip(marketplaceSource).use { it.addFile("plugin/content.txt", byteArrayOf()) }
|
||||
val marketplaceDestination = tempDir.resolve("plugins")
|
||||
val marketplaceDestination = tempDir.newDirectoryPath("plugins")
|
||||
val unpacked = marketplaceDestination.resolve("plugin/content.txt")
|
||||
|
||||
StartupActionScriptManager.addActionCommand(StartupActionScriptManager.UnzipCommand(marketplaceSource, marketplaceDestination))
|
||||
@@ -163,13 +160,10 @@ class StartupActionScriptManagerTest {
|
||||
|
||||
assertThat(unpacked).exists()
|
||||
assertThat(scriptFile).doesNotExist()
|
||||
tempDir.deleteRecursively()
|
||||
}
|
||||
|
||||
@Test fun `preserving non-marketplace commands`() {
|
||||
val tempDir = Files.createTempDirectory("test") // tempDir from class has 'marketplace' in path due to test name
|
||||
val regularFile = tempDir.resolve("temp.txt").createParentDirectories()
|
||||
Files.writeString(regularFile, "content")
|
||||
@Test fun `preserving non-MP commands`() {
|
||||
val regularFile = tempDir.newFileNio("temp.txt")
|
||||
assertThat(regularFile).exists()
|
||||
|
||||
StartupActionScriptManager.addActionCommand(StartupActionScriptManager.DeleteCommand(regularFile))
|
||||
@@ -178,18 +172,13 @@ class StartupActionScriptManagerTest {
|
||||
assertThat(regularFile).exists()
|
||||
assertThat(scriptFile).exists()
|
||||
assertThat(StartupActionScriptManager.loadActionScript(scriptFile)).hasSize(1)
|
||||
tempDir.deleteRecursively()
|
||||
}
|
||||
|
||||
@Test fun `executing mixed marketplace and non-marketplace commands`() {
|
||||
val tempDir = Files.createTempDirectory("test") // tempDir from class has 'marketplace' in path due to test name
|
||||
val marketplaceCopySource = tempDir.resolve("marketplace/file.txt").createParentDirectories()
|
||||
Files.writeString(marketplaceCopySource, "content")
|
||||
@Test fun `executing mixed MP and non-MP commands`() {
|
||||
val marketplaceCopySource = tempDir.newFileNio("marketplace/file.txt")
|
||||
val marketplaceCopyDest = marketplaceCopySource.resolveSibling("destination.txt")
|
||||
val regularFile = tempDir.resolve("regular/temp.txt").createParentDirectories()
|
||||
Files.writeString(regularFile, "content")
|
||||
val marketplaceDeleteFile = tempDir.resolve("marketplace/old.txt").createParentDirectories()
|
||||
Files.writeString(marketplaceDeleteFile, "old")
|
||||
val regularFile = tempDir.newFileNio("regular/temp.txt")
|
||||
val marketplaceDeleteFile = tempDir.newFileNio("marketplace/old.txt")
|
||||
|
||||
assertThat(marketplaceCopySource).exists()
|
||||
assertThat(marketplaceCopyDest).doesNotExist()
|
||||
@@ -209,23 +198,21 @@ class StartupActionScriptManagerTest {
|
||||
assertThat(regularFile).exists()
|
||||
assertThat(scriptFile).exists()
|
||||
assertThat(StartupActionScriptManager.loadActionScript(scriptFile)).hasSize(1)
|
||||
tempDir.deleteRecursively()
|
||||
}
|
||||
|
||||
@Test fun `executing marketplace commands from empty script`() {
|
||||
@Test fun `executing MP commands from empty script`() {
|
||||
assertThatCode { StartupActionScriptManager.executeMarketplaceCommandsFromActionScript() }.doesNotThrowAnyException()
|
||||
assertThat(scriptFile).doesNotExist()
|
||||
}
|
||||
|
||||
@Test fun `updating marketplace plugin`() {
|
||||
val tempDir = Files.createTempDirectory("test") // tempDir from class has 'marketplace' in path due to test name
|
||||
val pluginsDir = tempDir.resolve("plugins")
|
||||
@Test fun `updating MP plugin`() {
|
||||
val pluginsDir = tempDir.newDirectoryPath("plugins")
|
||||
val oldMarketplaceDir = pluginsDir.resolve("marketplace")
|
||||
val oldFile = oldMarketplaceDir.resolve("old-version.txt")
|
||||
oldFile.parent.createDirectories()
|
||||
Files.writeString(oldFile, "old content")
|
||||
|
||||
val marketplaceZip = tempDir.resolve("marketplace-1.2.3.zip").createParentDirectories()
|
||||
val marketplaceZip = tempDir.newFileNio("marketplace-1.2.3.zip")
|
||||
Compressor.Zip(marketplaceZip).use { zip ->
|
||||
zip.addFile("marketplace/new-version.txt", "new content".toByteArray())
|
||||
zip.addFile("marketplace/plugin.xml", "<plugin></plugin>".toByteArray())
|
||||
@@ -252,7 +239,6 @@ class StartupActionScriptManagerTest {
|
||||
assertThat(pluginXml).exists()
|
||||
assertThat(marketplaceZip).doesNotExist()
|
||||
assertThat(scriptFile).doesNotExist()
|
||||
tempDir.deleteRecursively()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user