Skip to content

Commit

Permalink
Add BotMockup type to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ryukinix committed Jul 24, 2020
1 parent 69031ac commit 853fba5
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions troll_shield_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,37 @@
package main

import (
"errors"
"testing"

telegram "github.com/go-telegram-bot-api/telegram-bot-api"
)

type BotMockup struct{}

func (bot *BotMockup) GetChatMember(c telegram.ChatConfigWithUser) (telegram.ChatMember, error) {
switch c.UserID {
case 1:
return telegram.ChatMember{Status: "member"}, nil
case 2:
return telegram.ChatMember{Status: "creator"}, nil
case 3:
return telegram.ChatMember{Status: "administrator"}, nil
case 4:
return telegram.ChatMember{Status: "left"}, nil
default:
return telegram.ChatMember{}, errors.New("user not found")
}
}

func (bot *BotMockup) KickChatMember(c telegram.KickChatMemberConfig) (telegram.APIResponse, error) {
return telegram.APIResponse{Ok: true}, nil
}

func (bot *BotMockup) Send(c telegram.Chattable) (telegram.Message, error) {
return telegram.Message{}, nil
}

func TestGetUserName(t *testing.T) {
user1 := telegram.User{
FirstName: "Rolisvaldo",
Expand Down

0 comments on commit 853fba5

Please sign in to comment.