mirror of
https://codeberg.org/VnPower/PixivFE
synced 2024-12-06 19:16:23 +01:00
Add unit tests for user_agent_list
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestGetRandomUserAgent(t *testing.T) {
|
||||
// Test that the function returns a non-empty string
|
||||
ua := GetRandomUserAgent()
|
||||
if ua == "" {
|
||||
t.Error("GetRandomUserAgent returned an empty string")
|
||||
}
|
||||
|
||||
// Test that the returned user agent is in the list
|
||||
found := false
|
||||
for _, builtinUA := range BuiltinUserAgentList {
|
||||
if ua == builtinUA {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
t.Error("GetRandomUserAgent returned a user agent not in BuiltinUserAgentList")
|
||||
}
|
||||
|
||||
// Test that BuiltinUserAgentList is not empty
|
||||
if len(BuiltinUserAgentList) == 0 {
|
||||
t.Error("BuiltinUserAgentList is empty")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user