summaryrefslogtreecommitdiff
path: root/href_test.go
blob: a571ee685e5350fc1cb18d1205b3b557f3d835ed (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
package main

import "testing"

type titleTest struct {
	URL   string
	Title string
}

var titleTestData = []titleTest{
	{
		URL:   `http://www.theinquirer.net/inquirer/news/2416607/linux-founder-says-you-must-be-on-drugs-if-youre-scared-of-ai`,
		Title: `Linux founder says you must be 'on drugs' if you're scared of AI- The Inquirer`,
	},
	{
		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`,
	},
}

func TestTitle(t *testing.T) {
	for _, test := range titleTestData {
		title, err := FetchTitle(test.URL)
		if err != nil {
			t.Error(test.URL, err)
		}
		if title != test.Title {
			t.Error("Expected", test.Title, "got", title)
		}
	}
}