github.com/argoproj/argo-events@v1.9.1/common/recurrence_test.go (about) 1 /* 2 Copyright 2018 BlackRock, Inc. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package common 18 19 import ( 20 "testing" 21 "time" 22 23 "github.com/smartystreets/goconvey/convey" 24 ) 25 26 func TestParseExclusionDate(t *testing.T) { 27 convey.Convey("Given an exclusion date", t, func() { 28 exDateString := "EXDATE:20060102T150405Z,20180510T021030Z" 29 30 convey.Convey("Parse exclusion dates", func() { 31 dates, err := ParseExclusionDates([]string{exDateString}) 32 33 convey.Convey("Make sure no error occurs", func() { 34 convey.So(err, convey.ShouldBeEmpty) 35 36 convey.Convey("Make sure only two dates are parsed", func() { 37 convey.So(len(dates), convey.ShouldEqual, 2) 38 39 convey.Convey("The first date must be 2nd of January", func() { 40 first := dates[0] 41 convey.So(first.Year(), convey.ShouldEqual, 2006) 42 convey.So(first.Month(), convey.ShouldEqual, time.January) 43 convey.So(first.Day(), convey.ShouldEqual, 2) 44 convey.So(first.Hour(), convey.ShouldEqual, 15) 45 convey.So(first.Minute(), convey.ShouldEqual, 4) 46 convey.So(first.Second(), convey.ShouldEqual, 5) 47 }) 48 49 convey.Convey("The second date must be 10th of May", func() { 50 second := dates[1] 51 convey.So(second.Year(), convey.ShouldEqual, 2018) 52 convey.So(second.Month(), convey.ShouldEqual, time.May) 53 convey.So(second.Day(), convey.ShouldEqual, 10) 54 convey.So(second.Hour(), convey.ShouldEqual, 2) 55 convey.So(second.Minute(), convey.ShouldEqual, 10) 56 convey.So(second.Second(), convey.ShouldEqual, 30) 57 }) 58 }) 59 }) 60 }) 61 }) 62 }