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
|
package main
import (
"os"
"path/filepath"
"reflect"
"testing"
)
func TestParse(t *testing.T) {
filename := "2025-02-19-isle-of-dogs.html"
data, err := os.ReadFile(filepath.Join("testdata", filename))
if err != nil {
t.Errorf("Could not read %v", filename)
}
want := []flat{
flat{
ID: 156522206,
Price: "£2,500",
},
flat{
ID: 158462822,
Price: "£3,000",
},
flat{
ID: 157948184,
Price: "£2,400",
}}
got, err := parse(data)
if err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(got, want) {
t.Errorf("Parse failed: got: %v, want: %v", got, want)
}
}
|