This repository has been archived on 2024-01-02. You can view files and clone it, but cannot push or open issues or pull requests.
2020-03-22 09:43:45 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func Test_checkBlacklist(t *testing.T) {
|
|
|
|
prepare := func() {
|
|
|
|
os.Clearenv()
|
2020-10-22 18:20:32 +00:00
|
|
|
_ = os.Setenv("BLACKLIST", "test1,test2,spam word")
|
2020-03-22 09:43:45 +00:00
|
|
|
appConfig, _ = parseConfig()
|
|
|
|
}
|
|
|
|
t.Run("Allowed values", func(t *testing.T) {
|
|
|
|
prepare()
|
2020-04-26 12:50:54 +00:00
|
|
|
if checkBlacklist([]string{"Hello", "How are you?"}) == true {
|
2020-03-22 09:43:45 +00:00
|
|
|
t.Error()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
t.Run("Forbidden values", func(t *testing.T) {
|
|
|
|
prepare()
|
2020-04-26 12:50:54 +00:00
|
|
|
if checkBlacklist([]string{"How are you?", "Hello TeSt1"}) == false {
|
2020-03-22 09:43:45 +00:00
|
|
|
t.Error()
|
|
|
|
}
|
|
|
|
})
|
2020-10-22 18:20:32 +00:00
|
|
|
t.Run("Multi word spam phrase", func(t *testing.T) {
|
|
|
|
prepare()
|
|
|
|
if checkBlacklist([]string{"This is a sPaM WORD"}) == false {
|
|
|
|
t.Error()
|
|
|
|
}
|
|
|
|
})
|
2020-03-22 09:43:45 +00:00
|
|
|
}
|