1package modeltest23import (4 "testing"56 "website-feeds/model"7)89func 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 false17 }1819 if got == nil {20 return true21 }2223 equal := CompareRedditSettings(t, got.Reddit, want.Reddit)2425 if got.DefaultNumPosts != want.DefaultNumPosts {26 t.Errorf(27 "DefaultNumPosts mismatch. got=%d, want=%d",28 got.DefaultNumPosts,29 want.DefaultNumPosts,30 )31 equal = false32 }3334 if got.MaxNumPosts != want.MaxNumPosts {35 t.Errorf(36 "MaxNumPosts mismatch. got=%d, want=%d",37 got.MaxNumPosts,38 want.MaxNumPosts,39 )40 equal = false41 }4243 if got.SiteFetchWait != want.SiteFetchWait {44 t.Errorf(45 "SiteFetchWait mismatch. got=%s, want=%s",46 got.SiteFetchWait,47 want.SiteFetchWait,48 )49 equal = false50 }5152 return equal53}5455func 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 false63 }6465 if got == nil {66 return true67 }6869 equal := true7071 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 = false78 }7980 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 = false87 }8889 return equal90}