pagemod_test.go 414 B

123456789101112131415161718
  1. package httpserver
  2. import (
  3. "os"
  4. "strings"
  5. "testing"
  6. )
  7. func TestReplaceDomains(t *testing.T) {
  8. data, _ := os.ReadFile("../test/webpage_external_domains.html")
  9. testDomain := "website.domain.org"
  10. got := replaceDomains(string(data), testDomain)
  11. os.WriteFile("post.html", data, os.ModePerm)
  12. if strings.Contains(got, "www.gstatic.com") {
  13. t.Error("Test failed! found unaccepted domain in page source")
  14. }
  15. }