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) } }) } }