1
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
659 B
Go

3 years ago
package main
import (
"os"
"testing"
)
func Test_checkBlacklist(t *testing.T) {
prepare := func() {
os.Clearenv()
3 years ago
_ = os.Setenv("BLACKLIST", "test1,test2,spam word")
3 years ago
appConfig, _ = parseConfig()
}
t.Run("Allowed values", func(t *testing.T) {
prepare()
if checkBlacklist([]string{"Hello", "How are you?"}) == true {
3 years ago
t.Error()
}
})
t.Run("Forbidden values", func(t *testing.T) {
prepare()
if checkBlacklist([]string{"How are you?", "Hello TeSt1"}) == false {
3 years ago
t.Error()
}
})
3 years ago
t.Run("Multi word spam phrase", func(t *testing.T) {
prepare()
if checkBlacklist([]string{"This is a sPaM WORD"}) == false {
t.Error()
}
})
3 years ago
}