A simple way to handle form submissions from static websites.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
659 B

4 years ago
3 years ago
4 years ago
4 years ago
4 years ago
3 years ago
4 years ago
  1. package main
  2. import (
  3. "os"
  4. "testing"
  5. )
  6. func Test_checkBlacklist(t *testing.T) {
  7. prepare := func() {
  8. os.Clearenv()
  9. _ = os.Setenv("BLACKLIST", "test1,test2,spam word")
  10. appConfig, _ = parseConfig()
  11. }
  12. t.Run("Allowed values", func(t *testing.T) {
  13. prepare()
  14. if checkBlacklist([]string{"Hello", "How are you?"}) == true {
  15. t.Error()
  16. }
  17. })
  18. t.Run("Forbidden values", func(t *testing.T) {
  19. prepare()
  20. if checkBlacklist([]string{"How are you?", "Hello TeSt1"}) == false {
  21. t.Error()
  22. }
  23. })
  24. t.Run("Multi word spam phrase", func(t *testing.T) {
  25. prepare()
  26. if checkBlacklist([]string{"This is a sPaM WORD"}) == false {
  27. t.Error()
  28. }
  29. })
  30. }