summaryrefslogtreecommitdiff
path: root/internal/links/find_test.go
blob: a4c952e1997789acfe6f00eccabdf2c756a97fc5 (plain)
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
package links

import (
	"strings"
	"testing"
)

const (
	ex1 = `
<html>
  <head>
    <title>Ex 1</title>
  <head>
  <body>
    <a href="https://example.com/">Example Page</a>
    <a href="/posts">Posts</a>
  </body>
</html>
`
)

func TestFindCountHrefs(t *testing.T) {
	r := strings.NewReader(ex1)
	hrefs, err := find(r)
	if err != nil {
		t.Error(err)
	}

	const expectedLen = 2

	if actualLen := len(hrefs); actualLen != expectedLen {
		t.Errorf("got %d, want %d", actualLen, expectedLen)
	}
}