-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core):
OneBotMember
实现 DeleteSupport
- Loading branch information
1 parent
2517cad
commit 5def48b
Showing
5 changed files
with
203 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...nTest/kotlin/love/forte/simbot/component/onebot/v11/core/actor/OneBotMemberDeleteTests.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package love.forte.simbot.component.onebot.v11.core.actor | ||
|
||
import io.ktor.client.* | ||
import io.ktor.client.engine.mock.* | ||
import io.ktor.utils.io.core.* | ||
import kotlinx.coroutines.test.runTest | ||
import kotlinx.serialization.json.Json | ||
import kotlinx.serialization.json.JsonObject | ||
import kotlinx.serialization.json.booleanOrNull | ||
import kotlinx.serialization.json.jsonPrimitive | ||
import love.forte.simbot.common.id.UIntID.Companion.ID | ||
import love.forte.simbot.common.id.ULongID.Companion.ID | ||
import love.forte.simbot.component.onebot.v11.core.actor.internal.OneBotMemberImpl | ||
import love.forte.simbot.component.onebot.v11.core.api.SetGroupKickApi | ||
import love.forte.simbot.component.onebot.v11.core.api.requestData | ||
import kotlin.test.Test | ||
import kotlin.test.assertFalse | ||
import kotlin.test.assertNotNull | ||
import kotlin.test.assertTrue | ||
|
||
|
||
/** | ||
* | ||
* @author ForteScarlet | ||
*/ | ||
class OneBotMemberDeleteTests { | ||
@Test | ||
fun oneBotMemberDeleteMarkTest() { | ||
var mark = OneBotMemberImpl.DeleteMark() | ||
assertFalse(mark.isRejectRequest) | ||
assertFalse(mark.isIgnoreFailure) | ||
|
||
mark = mark.rejectRequest() | ||
assertTrue(mark.isRejectRequest) | ||
|
||
mark = mark.ignoreFailure() | ||
assertTrue(mark.isIgnoreFailure) | ||
} | ||
|
||
@Test | ||
fun oneBotMemberDeleteTest() = runTest { | ||
HttpClient( | ||
MockEngine { reqData -> | ||
val json = reqData.body.toByteArray().decodeToString() | ||
val obj = Json.decodeFromString(JsonObject.serializer(), json) | ||
val rejectRequest = obj["reject_add_request"]?.jsonPrimitive?.booleanOrNull | ||
assertNotNull(rejectRequest) | ||
assertTrue(rejectRequest) | ||
respondOk("""{"retcode":0,"status":null,"data":null}""") | ||
} | ||
).use { client -> | ||
SetGroupKickApi.create(ULong.MAX_VALUE.ID, UInt.MAX_VALUE.ID, rejectAddRequest = true).requestData( | ||
client, | ||
"127.0.0.1" | ||
) | ||
} | ||
|
||
} | ||
|
||
} |