Files

53 lines
1.3 KiB
Go

package main
import (
"testing"
)
const (
UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36"
RateLimit = 1000
HTTPTimeout = 60
)
func TestGetAccount(t *testing.T) {
worker := NewDomainWorker("kiwifarms.cc", UserAgent, RateLimit, HTTPTimeout)
acct, err := worker.GetAccount("crunklord420")
if err != nil {
t.Error(err)
}
userID, ok := acct["id"].(string)
if !ok {
t.Error("JSON 'id' string field is missing/wrong type")
}
if userID != "9koPCTgOSOoI3Wcj9k" {
t.Error("userID should be 9koPCTgOSOoI3Wcj9k, is: " + userID)
}
}
func TestFindUserID(t *testing.T) {
worker := NewDomainWorker("mastodon.social", UserAgent, RateLimit, HTTPTimeout)
userID, err := worker.FindUserID("Gargron")
if err != nil {
t.Error(err)
}
if userID != "1" {
t.Errorf("userID should be 1, is: %s", userID)
}
}
func TestGetAccountByUsername(t *testing.T) {
worker := NewDomainWorker("gab.com", UserAgent, RateLimit, HTTPTimeout)
data, err := worker.GetAccountByUsername("billstclair")
if err != nil {
t.Error(err)
}
userID, ok := data["id"].(string)
if !ok {
t.Error("JSON 'id' string field is missing/wrong type")
}
if userID != "33149" {
t.Error("userID should be 33149, is: " + userID)
}
}