aboutsummaryrefslogtreecommitdiff
path: root/main_test.go
diff options
context:
space:
mode:
authorEvgeny Kuznetsov <evgeny@kuznetsov.md>2020-02-05 09:28:20 +0300
committerEvgeny Kuznetsov <evgeny@kuznetsov.md>2020-02-05 09:28:20 +0300
commit85caee2d9cad1f022e7101b1a04016f92fda64d1 (patch)
tree5f396c2094481f1a806ad219669ebf75ff6af6a8 /main_test.go
parentec0baaa14313e84af97ea1783559e5ccdc293c8e (diff)
downloadradiorus-rss-85caee2d9cad1f022e7101b1a04016f92fda64d1.tar.gz
radiorus-rss-85caee2d9cad1f022e7101b1a04016f92fda64d1.zip
more testing
Diffstat (limited to 'main_test.go')
-rw-r--r--main_test.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/main_test.go b/main_test.go
index d403753..73dc0c8 100644
--- a/main_test.go
+++ b/main_test.go
@@ -29,6 +29,7 @@ import (
"strings"
"sync"
"testing"
+ "time"
"github.com/gorilla/feeds"
)
@@ -279,3 +280,24 @@ func TestStripLink(t *testing.T) {
}
}
}
+
+func TestParseDate(t *testing.T) {
+ type testval struct {
+ b [][]byte
+ d time.Time
+ }
+
+ var tests = []testval{
+ {[][]byte{[]byte{}, []byte("24"), []byte("11"), []byte(`2019`), []byte("14"), []byte("10")}, time.Date(2019, time.November, 24, 14, 10, 0, 0, moscow)},
+ {[][]byte{[]byte("foo"), []byte("bar"), []byte("baz"), []byte("qux"), []byte("none")}, time.Date(1970, time.January, 1, 0, 0, 0, 0, moscow)},
+ {[][]byte{}, time.Date(1970, time.January, 1, 0, 0, 0, 0, moscow)},
+ }
+
+ for _, test := range tests {
+ got := parseDate(test.b)
+ want := test.d
+ if !got.Equal(want) {
+ t.Error("want:", want, "got:", got)
+ }
+ }
+}