Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✅ Rename test classes to follow naming conventions #1659

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.crosspaste.app

import com.crosspaste.path.TestPathProviderMock.Companion.testUseMockTestPathProvider
import com.crosspaste.path.TestAppPathProviderMock.useMockAppPathProvider
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
Expand All @@ -12,7 +12,7 @@ class AppLockTest {

@Test
fun testSingleInstanceLock() {
testUseMockTestPathProvider { _, _, _, _ ->
useMockAppPathProvider { _, _, _, _ ->
runBlocking {
val job1 =
launch {
Expand Down Expand Up @@ -43,7 +43,7 @@ class AppLockTest {

@Test
fun testLockRelease() {
testUseMockTestPathProvider { _, _, _, _ ->
useMockAppPathProvider { _, _, _, _ ->
runBlocking {
assertTrue(DesktopAppLaunch.acquireLock().first, "Instance should be able to acquire the lock initially")
DesktopAppLaunch.releaseLock()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertNull

class TestAppWindowManager {
class AppWindowManagerTest {

@Test
fun testMockTestAppWindowManager() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.crosspaste.path

import com.crosspaste.app.AppFileType
import com.crosspaste.path.TestAppPathProviderMock.useMockAppPathProvider
import com.crosspaste.platform.currentPlatform
import com.crosspaste.utils.noOptionParent
import kotlin.test.Ignore
import kotlin.test.Test
import kotlin.test.assertEquals

class AppPathProviderTest {

@Test
fun testMockProvider() {
useMockAppPathProvider { tempPasteAppPath, tempUserHome, tempPasteAppJarPath, tempUserPath ->
assertEquals(tempPasteAppPath, DesktopAppPathProvider.pasteAppPath)
assertEquals(tempUserHome, DesktopAppPathProvider.userHome)
assertEquals(tempPasteAppJarPath, DesktopAppPathProvider.pasteAppJarPath)
assertEquals(tempUserPath, DesktopAppPathProvider.pasteUserPath)
}
}

@Test
@Ignore
fun testAppPathProvider() {
val configPath = DesktopAppPathProvider.resolve("test.config", AppFileType.USER)

assertEquals("test.config", configPath.name)
val currentPlatform = currentPlatform()
if (currentPlatform.isMacos()) {
assertEquals("CrossPaste", configPath.noOptionParent.name)
} else if (currentPlatform.isWindows()) {
assertEquals(".crosspaste", configPath.noOptionParent.name)
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.crosspaste.path

import io.mockk.every
import io.mockk.mockkObject
import io.mockk.unmockkObject
import okio.Path
import okio.Path.Companion.toOkioPath
import java.nio.file.Files

object TestAppPathProviderMock {

@Synchronized
fun useMockAppPathProvider(testAction: (Path, Path, Path, Path) -> Unit) {
try {
mockkObject(DesktopAppPathProvider)

// Create temporary directories
val tempPasteAppPath = Files.createTempDirectory("tempPasteAppPath").toOkioPath()
val tempUserHome = Files.createTempDirectory("tempUserHome").toOkioPath()
val tempPasteAppJarPath = Files.createTempDirectory("tempPasteAppJarPath").toOkioPath()
val tempUserPath = Files.createTempDirectory("tempUserPath").toOkioPath()

tempPasteAppPath.toFile().deleteOnExit()
tempUserHome.toFile().deleteOnExit()
tempPasteAppJarPath.toFile().deleteOnExit()
tempUserPath.toFile().deleteOnExit()

every { DesktopAppPathProvider.pasteAppPath } returns tempPasteAppPath
every { DesktopAppPathProvider.userHome } returns tempUserHome
every { DesktopAppPathProvider.pasteAppJarPath } returns tempPasteAppJarPath
every { DesktopAppPathProvider.pasteUserPath } returns tempUserPath

testAction(tempPasteAppPath, tempUserHome, tempPasteAppJarPath, tempUserPath)
} finally {
unmockkObject(DesktopAppPathProvider)
}
}
}

This file was deleted.

Loading