package main import "testing" func TestTitle(t *testing.T) { testCases := []struct { url, title string }{ {`https://www.linux.org.ru`, `LINUX.ORG.RU - Русская информация об ОС Linux`}, {`http://www.opennet.ru`, `Проект OpenNet - всё, что связано с открытым ПО, открытыми технологиями, Linux, BSD и Unix`}, {`http://www.openbsd.org`, `OpenBSD`}, {`http://undeadly.org`, `OpenBSD Journal: A resource for the OpenBSD community`}, {`https://github.com/dls/house/blob/master/kernel/SimpleExec.hs`, `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) } }) } }