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