summaryrefslogtreecommitdiff
path: root/href_test.go
blob: dfeb091f1422e9eb8c07489cd3f0602c17a62b67 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main

import "testing"

func TestTitle(t *testing.T) {
	testCases := []struct {
		URL   string
		Title string
	}{
		{
			URL:   `https://www.linux.org.ru`,
			Title: `LINUX.ORG.RU - Русская информация об ОС Linux`,
		},
		{
			URL:   `http://www.opennet.ru`,
			Title: `Проект OpenNet - всё, что связано с открытым ПО, открытыми технологиями, Linux, BSD и Unix`,
		},
		{
			URL:   `http://www.openbsd.org`,
			Title: `OpenBSD`,
		},
		{
			URL:   `http://undeadly.org`,
			Title: `OpenBSD Journal: A resource for the OpenBSD community`,
		},
		{
			URL:   `https://github.com/dls/house/blob/master/kernel/SimpleExec.hs`,
			Title: `house/SimpleExec.hs at master · dls/house · GitHub`,
		},
	}
	for _, tc := range testCases {
		t.Run(tc.URL, func(t *testing.T) {
			title, err := getTitle(tc.URL)
			if err != nil {
				t.Error(tc.URL, err)
			}
			if title != tc.Title {
				t.Errorf("got %v, want %v", title, tc.Title)
			}
		})
	}
}