| 1 | package icsscip-go gomod github.com/arran4/golang-ical . `github.com/arran4/golang-ical`/ |
| 2 | |
| 3 | import ( |
| 4 | "stringsscip-go gomod github.com/golang/go/src go1.13 strings/" |
| 5 | "testingscip-go gomod github.com/golang/go/src go1.13 testing/" |
| 6 | "timescip-go gomod github.com/golang/go/src go1.13 time/" |
| 7 | |
| 8 | "github.com/stretchr/testify/assertscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/" |
| 9 | ) |
| 10 | |
| 11 | func TestSetDurationscip-go gomod github.com/arran4/golang-ical . `github.com/arran4/golang-ical`/TestSetDuration().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 12 | date, _ := timescip-go gomod github.com/golang/go/src go1.13 time/.Parsescip-go gomod github.com/golang/go/src go1.13 time/Parse().(timescip-go gomod github.com/golang/go/src go1.13 time/.RFC822scip-go gomod github.com/golang/go/src go1.13 time/RFC822., timescip-go gomod github.com/golang/go/src go1.13 time/.RFC822scip-go gomod github.com/golang/go/src go1.13 time/RFC822.) |
| 13 | duration := timescip-go gomod github.com/golang/go/src go1.13 time/.Durationscip-go gomod github.com/golang/go/src go1.13 time/Duration#(float64(timescip-go gomod github.com/golang/go/src go1.13 time/.Hourscip-go gomod github.com/golang/go/src go1.13 time/Hour.) * 2) |
| 14 | |
| 15 | testCases := []struct { |
| 16 | name string |
| 17 | start timescip-go gomod github.com/golang/go/src go1.13 time/.Timescip-go gomod github.com/golang/go/src go1.13 time/Time# |
| 18 | end timescip-go gomod github.com/golang/go/src go1.13 time/.Timescip-go gomod github.com/golang/go/src go1.13 time/Time# |
| 19 | output string |
| 20 | }{ |
| 21 | { |
| 22 | name: "test set duration - start", |
| 23 | start: date, |
| 24 | output: `BEGIN:VEVENT |
| 25 | UID:test-duration |
| 26 | DTSTART:20060102T150400Z |
| 27 | DTEND:20060102T170400Z |
| 28 | END:VEVENT |
| 29 | `, |
| 30 | }, |
| 31 | { |
| 32 | name: "test set duration - end", |
| 33 | end: date, |
| 34 | output: `BEGIN:VEVENT |
| 35 | UID:test-duration |
| 36 | DTEND:20060102T150400Z |
| 37 | DTSTART:20060102T130400Z |
| 38 | END:VEVENT |
| 39 | `, |
| 40 | }, |
| 41 | } |
| 42 | |
| 43 | for _, tc := range testCases { |
| 44 | t.Runscip-go gomod github.com/golang/go/src go1.13 testing/T#Run().(tc.name, func(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 45 | e := NewEventscip-go gomod github.com/arran4/golang-ical . `github.com/arran4/golang-ical`/NewEvent().("test-duration") |
| 46 | if !tc.start.IsZeroscip-go gomod github.com/golang/go/src go1.13 time/Time#IsZero().() { |
| 47 | e.SetStartAtscip-go gomod github.com/arran4/golang-ical . `github.com/arran4/golang-ical`/VEvent#SetStartAt().(tc.start) |
| 48 | } |
| 49 | if !tc.end.IsZeroscip-go gomod github.com/golang/go/src go1.13 time/Time#IsZero().() { |
| 50 | e.SetEndAtscip-go gomod github.com/arran4/golang-ical . `github.com/arran4/golang-ical`/VEvent#SetEndAt().(tc.end) |
| 51 | } |
| 52 | err := e.SetDurationscip-go gomod github.com/arran4/golang-ical . `github.com/arran4/golang-ical`/VEvent#SetDuration().(duration) |
| 53 | |
| 54 | // we're not testing for encoding here so lets make the actual output line breaks == expected line breaks |
| 55 | text := stringsscip-go gomod github.com/golang/go/src go1.13 strings/.Replacescip-go gomod github.com/golang/go/src go1.13 strings/Replace().(e.Serializescip-go gomod github.com/arran4/golang-ical . `github.com/arran4/golang-ical`/VEvent#Serialize().(), "\r\n", "\n", -1) |
| 56 | |
| 57 | assertscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/Equal().(t, tc.output, text) |
| 58 | assertscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.7.0 `github.com/stretchr/testify/assert`/Equal().(t, nil, err) |
| 59 | }) |
| 60 | } |
| 61 | } |