-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscrapping_test.go
52 lines (47 loc) · 950 Bytes
/
scrapping_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
52
package main
import (
"io"
"log"
"os"
"testing"
)
func TestGetFromLiquipedia(t *testing.T) {
response, err := getFromLiquipedia("starcraft2")
if err != nil {
t.Fatal(err.Error())
return
}
if response.StatusCode != 200 {
t.Fatal(response.Status)
return
}
_, err = io.ReadAll(response.Body)
if err != nil {
t.Fatal(err.Error())
return
}
}
func TestParseJSON(t *testing.T) {
input := []byte(`{"parse":{"title":"Liquipedia:Upcoming and ongoing matches","pageid":64908,"revid":2145797,"text":{"*":"<div class=\"mw-parser-output\">"}}}`)
_, err := parseJSON(input)
if err != nil {
t.Fatal(err.Error())
return
}
}
func Test_fetchGames(t *testing.T) {
// Read all testing data
_, err := os.ReadFile("resources/scrapping_test_get_wikis")
if err != nil {
log.Fatal(err)
}
games, err := fetchGames()
if err != nil {
t.Fatal(err.Error())
return
}
if len(games) == 0 {
t.Fatal("No games found.")
return
}
}