~chrisppy/go-barefeed

ref: 63fc114fd6c8a8779e44c7042a5c1a6f543a76fb go-barefeed/link_test.go -rw-r--r-- 1.0 KiB
63fc114fChris Palmer updates from schema 4 months ago
                                                                                
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
package barefeed

import "testing"

func testLinks(t *testing.T, expected, actual Links) {
	if len(expected) != len(actual) {
		t.Errorf("Expected %d links, actual %d links", len(expected), len(actual))
	}
	for j := 0; j < len(expected); j++ {
		if expected[j].URL != actual[j].URL {
			t.Errorf("Expected %s, actual %s", expected[j].URL, actual[j].URL)
		}
		if expected[j].LinkType != actual[j].LinkType {
			t.Errorf("Expected %s, actual %s", expected[j].LinkType, actual[j].LinkType)
		}
		if expected[j].Rel != actual[j].Rel {
			t.Errorf("Expected %s, actual %s", expected[j].Rel, actual[j].Rel)
		}
		if expected[j].Length != actual[j].Length {
			t.Errorf("Expected %d, actual %d", expected[j].Length, actual[j].Length)
		}
	}
}

func getLinks() Links {
	a := Link{
		URL:      "https://example.com/entry.mp3",
		LinkType: "audio/mp3",
		Rel:      "enclosure",
		Length:   50416767,
	}

	b := Link{
		URL:      "https://example.com/feed.xml",
		LinkType: "plain/html",
		Rel:      "self",
		Length:   123,
	}

	return Links{a, b}
}