Skip to content

Commit

Permalink
Add addOtherClient for GroupExtensions for tests, add other clients…
Browse files Browse the repository at this point in the history
… before running tests for MessageSyncEvent
  • Loading branch information
Him188 committed Jun 13, 2022
1 parent 0332395 commit 0a8fc34
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ import net.mamoe.mirai.Mirai
import net.mamoe.mirai.contact.*
import net.mamoe.mirai.internal.BotAccount
import net.mamoe.mirai.internal.QQAndroidBot
import net.mamoe.mirai.internal.contact.FriendImpl
import net.mamoe.mirai.internal.contact.GroupImpl
import net.mamoe.mirai.internal.contact.NormalMemberImpl
import net.mamoe.mirai.internal.contact.StrangerImpl
import net.mamoe.mirai.internal.asQQAndroidBot
import net.mamoe.mirai.internal.contact.*
import net.mamoe.mirai.internal.contact.info.FriendInfoImpl
import net.mamoe.mirai.internal.contact.info.GroupInfoImpl
import net.mamoe.mirai.internal.contact.info.MemberInfoImpl
Expand Down Expand Up @@ -211,4 +209,15 @@ internal interface GroupExtensions {
members.delegate.add(NormalMemberImpl(this.cast(), this.coroutineContext, info))
return this
}

fun Bot.addOtherClient(
appId: Int,
platform: Platform = Platform.IOS,
deviceName: String = "my device $appId",
deviceKind: String = "my device kind $appId"
): OtherClient {
return bot.asQQAndroidBot().createOtherClient(OtherClientInfo(appId, platform, deviceName, deviceKind)).also {
this.otherClients.delegate.add(it)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ internal class MessageSyncTest : AbstractNoticeProcessorTest() {
addMember(1230001, permission = MemberPermission.OWNER)
addMember(1230002, permission = MemberPermission.MEMBER)
}
addOtherClient(537067835)
}

runTest().toList().run {
Expand Down Expand Up @@ -162,6 +163,7 @@ internal class MessageSyncTest : AbstractNoticeProcessorTest() {

setBot(1230002).apply {
addFriend(1230001)
addOtherClient(537067835)
}

runTest().toList().run {
Expand Down

0 comments on commit 0a8fc34

Please sign in to comment.