From 1d2ca509c77cbb2af0475b1319cd840f8ce9a1d0 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sat, 6 Jul 2019 17:17:46 +0200 Subject: Split in packages --- href_test.go | 63 ------------------------------------------------------------ 1 file changed, 63 deletions(-) delete mode 100644 href_test.go (limited to 'href_test.go') diff --git a/href_test.go b/href_test.go deleted file mode 100644 index fb4667c..0000000 --- a/href_test.go +++ /dev/null @@ -1,63 +0,0 @@ -package main - -import ( - "io" - "net/http" - "net/http/httptest" - "os" - "testing" -) - -func TestTitle(t *testing.T) { - testCases := []struct { - fixture, title, contentType string - }{ - { - `testdata/linux.org.ru`, - `LINUX.ORG.RU - Русская информация об ОС Linux`, - `text/html;charset=utf-8`, - }, - { - `testdata/opennet.ru`, - `Проект OpenNet - всё, что связано с открытым ПО, открытыми технологиями, Linux, BSD и Unix`, - `text/html; charset=koi8-r`, - }, - { - `testdata/openbsd.org`, - `OpenBSD`, - `text/html`, - }, - { - `testdata/undeadly.org`, - `OpenBSD Journal: A resource for the OpenBSD community`, - `text/html`, - }, - { - `testdata/deepnested.html`, - `!`, - `text/html`, - }, - } - for _, tc := range testCases { - t.Run(tc.fixture, func(t *testing.T) { - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - fd, err := os.Open(tc.fixture) - if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } - defer fd.Close() - w.Header().Set("Content-Type", tc.contentType) - io.Copy(w, fd) - })) - defer ts.Close() - title, err := getTitle(ts.URL) - if err != nil { - t.Error(tc.fixture, err) - } - if title != tc.title { - t.Errorf("got %v, want %v", title, tc.title) - } - }) - } -} -- cgit v1.2.3