website-feeds

Make RSS feeds of your favorite "vote on posts" websites

git clone https://code.pdelong.com/website-feeds.git

 1package modeltest
 2
 3import (
 4	"testing"
 5
 6	"website-feeds/model"
 7)
 8
 9func CompareSettings(t *testing.T, got, want *model.Settings) bool {
10	if (got == nil) != (want == nil) {
11		t.Errorf(
12			"nil settings mismatch. got=%t, want=%t",
13			got == nil,
14			want == nil,
15		)
16		return false
17	}
18
19	if got == nil {
20		return true
21	}
22
23	equal := CompareRedditSettings(t, got.Reddit, want.Reddit)
24
25	if got.DefaultNumPosts != want.DefaultNumPosts {
26		t.Errorf(
27			"DefaultNumPosts mismatch. got=%d, want=%d",
28			got.DefaultNumPosts,
29			want.DefaultNumPosts,
30		)
31		equal = false
32	}
33
34	if got.MaxNumPosts != want.MaxNumPosts {
35		t.Errorf(
36			"MaxNumPosts mismatch. got=%d, want=%d",
37			got.MaxNumPosts,
38			want.MaxNumPosts,
39		)
40		equal = false
41	}
42
43	if got.SiteFetchWait != want.SiteFetchWait {
44		t.Errorf(
45			"SiteFetchWait mismatch. got=%s, want=%s",
46			got.SiteFetchWait,
47			want.SiteFetchWait,
48		)
49		equal = false
50	}
51
52	return equal
53}
54
55func CompareRedditSettings(t *testing.T, got, want *model.RedditSettings) bool {
56	if (got == nil) != (want == nil) {
57		t.Errorf(
58			"nil reddit settings mismatch. got=%t, want=%t",
59			got == nil,
60			want == nil,
61		)
62		return false
63	}
64
65	if got == nil {
66		return true
67	}
68
69	equal := true
70
71	if got.ClientID != want.ClientID {
72		t.Errorf(
73			"Reddit ClientID mismatch. got=%s, want=%s",
74			got.ClientID,
75			want.ClientID,
76		)
77		equal = false
78	}
79
80	if got.ClientSecret != want.ClientSecret {
81		t.Errorf(
82			"Reddit ClientSecret mismatch. got=%s, want=%s",
83			got.ClientSecret,
84			want.ClientSecret,
85		)
86		equal = false
87	}
88
89	return equal
90}