mirror of
https://github.com/LamGC/ScalaBot.git
synced 2025-04-29 22:27:31 +00:00
test(config): 补全单元测试用例.
由于 `MavenRepositoryConfig.authentication` 有关联的序列化器, 因此不可忽略对该属性进行检查; 现已补充单元测试用例以确保反序列化结果正确.
This commit is contained in:
parent
db010d6c86
commit
06acc78180
@ -3,10 +3,14 @@ package net.lamgc.scalabot.config
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.GsonBuilder
|
||||
import com.google.gson.JsonObject
|
||||
import io.mockk.every
|
||||
import io.mockk.mockk
|
||||
import io.mockk.verify
|
||||
import net.lamgc.scalabot.config.serializer.*
|
||||
import org.eclipse.aether.artifact.Artifact
|
||||
import org.eclipse.aether.artifact.DefaultArtifact
|
||||
import org.eclipse.aether.repository.Authentication
|
||||
import org.eclipse.aether.repository.AuthenticationContext
|
||||
import org.eclipse.aether.repository.Proxy
|
||||
import org.intellij.lang.annotations.Language
|
||||
import org.junit.jupiter.api.Assertions
|
||||
@ -347,8 +351,8 @@ internal class MavenRepositoryConfigTest {
|
||||
"enableReleases": false,
|
||||
"enableSnapshots": true,
|
||||
"authentication": {
|
||||
"username": "username",
|
||||
"password": "password"
|
||||
"username": "testUser",
|
||||
"password": "testPassword"
|
||||
}
|
||||
}
|
||||
""".trimIndent()
|
||||
@ -368,6 +372,16 @@ internal class MavenRepositoryConfigTest {
|
||||
assertEquals(false, config.enableReleases)
|
||||
assertEquals(true, config.enableSnapshots)
|
||||
assertNotNull(config.authentication)
|
||||
|
||||
val authContext = mockk<AuthenticationContext> {
|
||||
every { put(ofType(String::class), any()) } answers { }
|
||||
}
|
||||
config.authentication!!.fill(authContext, null, emptyMap())
|
||||
|
||||
verify {
|
||||
authContext.put(any(), "testUser")
|
||||
authContext.put(any(), "testPassword".toCharArray())
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user