From 602dcb4ec617634d1fed182ac0309123992e43c6 Mon Sep 17 00:00:00 2001 From: Dmitry Ilvokhin Date: Sun, 23 Feb 2025 16:20:33 +0000 Subject: Implement URL fetching and page parsing --- flatbot_test.go | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 flatbot_test.go (limited to 'flatbot_test.go') diff --git a/flatbot_test.go b/flatbot_test.go new file mode 100644 index 0000000..0308295 --- /dev/null +++ b/flatbot_test.go @@ -0,0 +1,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) + } +} -- cgit v1.2.3-70-g09d2