74 lines
1.7 KiB
Go
74 lines
1.7 KiB
Go
|
package match
|
||
|
|
||
|
import (
|
||
|
"net/url"
|
||
|
"strings"
|
||
|
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func TestLeague_ListSources(t *testing.T) {
|
||
|
t.Log("Testing matchendirect.fr sources...")
|
||
|
scheduleUrl := "http://www.matchendirect.fr/france/ligue-1/"
|
||
|
league := League{
|
||
|
ScheduleUrl: &scheduleUrl,
|
||
|
}
|
||
|
sources, err := league.ListSources()
|
||
|
if err != nil {
|
||
|
t.Error(err)
|
||
|
}
|
||
|
if len(sources) == 0 {
|
||
|
t.Errorf("no sources found")
|
||
|
}
|
||
|
for _, s := range sources {
|
||
|
if !strings.HasPrefix(s.Url.String(), "http://www.matchendirect.fr/france/ligue-1/") {
|
||
|
t.Errorf("unexpected source url %s", s.Url)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
t.Log("Testing eurosport.fr sources...")
|
||
|
scheduleUrl = "https://www.eurosport.fr/tennis/open-d-australie-messieurs/2020/standing.shtml"
|
||
|
league = League{
|
||
|
ScheduleUrl: &scheduleUrl,
|
||
|
}
|
||
|
sources, err = league.ListSources()
|
||
|
if err != nil {
|
||
|
t.Error(err)
|
||
|
}
|
||
|
if len(sources) == 0 {
|
||
|
t.Errorf("no sources found")
|
||
|
}
|
||
|
for _, s := range sources {
|
||
|
if !strings.HasPrefix(s.Url.String(), "https://www.eurosport.fr/") {
|
||
|
t.Errorf("unexpected source url %s", s.Url)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
t.Log("Testing rugbyrama.fr sources...")
|
||
|
scheduleUrl = "https://www.rugbyrama.fr/rugby/top-14/calendar-result.shtml"
|
||
|
league = League{
|
||
|
ScheduleUrl: &scheduleUrl,
|
||
|
}
|
||
|
sources, err = league.ListSources()
|
||
|
if err != nil {
|
||
|
t.Error(err)
|
||
|
}
|
||
|
if len(sources) == 0 {
|
||
|
t.Errorf("no sources found")
|
||
|
}
|
||
|
for _, s := range sources {
|
||
|
if !strings.HasPrefix(s.Url.String(), "https://www.rugbyrama.fr/") {
|
||
|
t.Errorf("unexpected source url %s", s.Url)
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func TestSource_GetMatches(t *testing.T) {
|
||
|
sourceUrl, _ := url.Parse("https://www.matchendirect.fr/france/ligue-1/2020-37/")
|
||
|
source := &Source{
|
||
|
League: &League{Id: 1},
|
||
|
Url: sourceUrl,
|
||
|
}
|
||
|
source.GetMatches()
|
||
|
}
|