2020-07-14 04:07:30 +02:00
package utils
2022-01-21 05:01:05 +01:00
import (
"testing"
)
2020-07-14 04:07:30 +02:00
func TestUserAgent ( t * testing . T ) {
testAgents := [ ] string {
"Pleroma 1.0.0-1168-ge18c7866-pleroma-dot-site; https://pleroma.site info@pleroma.site" ,
"Mastodon 1.2.3 Bot" ,
2020-09-01 05:36:52 +02:00
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Safari/605.1.15 (Applebot/0.1; +http://www.apple.com/go/applebot)" ,
2021-09-14 02:14:30 +02:00
"WhatsApp" ,
2020-07-14 04:07:30 +02:00
}
for _ , agent := range testAgents {
if ! IsUserAgentABot ( agent ) {
t . Error ( "Incorrect parsing of useragent" , agent )
}
}
}
2022-01-21 05:01:05 +01:00
func TestGetHashtagsFromText ( t * testing . T ) {
text := ` Some text with a # hashtag goes here . \ n \ n
Another # secondhashtag , goes here . \ n \ n
# thirdhashtag `
hashtags := GetHashtagsFromText ( text )
if hashtags [ 0 ] != "#hashtag" || hashtags [ 1 ] != "#secondhashtag" || hashtags [ 2 ] != "#thirdhashtag" {
t . Error ( "Incorrect hashtags fetched from text." )
}
}