summaryrefslogtreecommitdiff
path: root/href_test.go
blob: 864b7022aa5839f25fa5d79b24458648a5b11532 (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
	Broken bool
}

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`,
		Broken: false,
	},
	{
		URL:    `http://www.ffoms.ru/portal/page/portal/top/index`,
		Title:  `Федеральный Фонд Обязательного Медицинского Страхования`,
		Broken: true, // This site is just fucked up beyond all repair
	},
	{
		URL:    `https://www.linux.org.ru`,
		Title:  `LINUX.ORG.RU - Русская информация об ОС Linux`,
		Broken: false,
	},
}

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