aboutsummaryrefslogtreecommitdiff
path: root/brokenlinks_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'brokenlinks_test.go')
-rw-r--r--brokenlinks_test.go60
1 files changed, 0 insertions, 60 deletions
diff --git a/brokenlinks_test.go b/brokenlinks_test.go
index 1c43937..2c8ad15 100644
--- a/brokenlinks_test.go
+++ b/brokenlinks_test.go
@@ -4,73 +4,13 @@
package jarink_test
import (
- "log"
"net/http"
- "os"
"testing"
- "time"
"git.sr.ht/~shulhan/jarink"
- libnet "git.sr.ht/~shulhan/pakakeh.go/lib/net"
"git.sr.ht/~shulhan/pakakeh.go/lib/test"
)
-// The test run two web servers that serve content on "testdata/web/".
-// The first web server is the one that we want to scan.
-// The second web server is external web server, where HTML pages should not
-// be parsed.
-
-const testAddress = `127.0.0.1:11836`
-const testExternalAddress = `127.0.0.1:11900`
-
-func TestMain(m *testing.M) {
- log.SetFlags(0)
- var httpDirWeb = http.Dir(`testdata/web`)
- var fshandle = http.FileServer(httpDirWeb)
-
- go func() {
- var mux = http.NewServeMux()
- mux.Handle(`/`, fshandle)
- var testServer = &http.Server{
- Addr: testAddress,
- Handler: mux,
- ReadTimeout: 10 * time.Second,
- WriteTimeout: 10 * time.Second,
- MaxHeaderBytes: 1 << 20,
- }
- var err = testServer.ListenAndServe()
- if err != nil {
- log.Fatal(err)
- }
- }()
- go func() {
- var mux = http.NewServeMux()
- mux.Handle(`/`, fshandle)
- var testServer = &http.Server{
- Addr: testExternalAddress,
- Handler: mux,
- ReadTimeout: 10 * time.Second,
- WriteTimeout: 10 * time.Second,
- MaxHeaderBytes: 1 << 20,
- }
- var err = testServer.ListenAndServe()
- if err != nil {
- log.Fatal(err)
- }
- }()
-
- var err = libnet.WaitAlive(`tcp`, testAddress, 5*time.Second)
- if err != nil {
- log.Fatal(err)
- }
- err = libnet.WaitAlive(`tcp`, testExternalAddress, 5*time.Second)
- if err != nil {
- log.Fatal(err)
- }
-
- os.Exit(m.Run())
-}
-
func TestBrokenlinks(t *testing.T) {
var testUrl = `http://` + testAddress