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