summaryrefslogtreecommitdiff
path: root/href_test.go
blob: 430eafc51cd2c3c11bed556e134c3061916a858f (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)
			}
		})
	}
}