-
Notifications
You must be signed in to change notification settings - Fork 0
/
calendar_test.go
51 lines (47 loc) · 1.21 KB
/
calendar_test.go
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
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"bytes"
"github.com/PuerkitoBio/goquery"
ics "github.com/arran4/golang-ical"
"log"
"os"
"testing"
)
type QueriesMock struct {
data []Query
}
func (queries QueriesMock) createCalendar(document *goquery.Document, player Query) (*ics.Calendar, error) {
//TODO implement me
panic("implement me")
}
func TestCreateCalendar(t *testing.T) {
// Read all data from file resources/scrapping_test_data.html
data, err := os.ReadFile("resources/scrapping_test_data_html")
if err != nil {
log.Fatal(err)
}
// Load the HTML document
reader := bytes.NewReader(data)
var document *goquery.Document
document, err = goquery.NewDocumentFromReader(reader)
if err != nil {
log.Fatal(err)
}
// Create iCalendar
myQuery := Queries{data: []Query{{game: "starcraft2", players: []string{"Maru", "Serral"}}}}
cal, err := myQuery.createCalendar(document, myQuery.data[0])
if err != nil {
t.Fatal(err)
}
// Check identical IDs
events := cal.Events()
var iteratedEvents []string
for i := 0; i < len(events); i++ {
for j := 0; j < len(iteratedEvents); j++ {
if iteratedEvents[j] == events[i].Id() {
t.Fatal("Identical ID between two events.")
}
}
_ = append(iteratedEvents, events[i].Id())
}
}