-
-
Notifications
You must be signed in to change notification settings - Fork 35
/
podcast_internals_test.go
61 lines (50 loc) · 1.29 KB
/
podcast_internals_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package podcast
import (
"bytes"
"errors"
"github.com/stretchr/testify/assert"
"io"
"testing"
)
func TestStringError(t *testing.T) {
t.Parallel()
// arrange
e := "TestEncodeError error result"
p := Podcast{}
p.encode = func(w io.Writer, o interface{}) error {
return errors.New(e)
}
// act
r := p.String()
// assert
assert.Contains(t, r, e)
}
func TestEncodeError(t *testing.T) {
t.Parallel()
// arrange
p := New("", "", "", nil, nil)
b := []byte{}
w := bytes.NewBuffer(b)
c := new(chan bool)
// act
err := p.encode(w, c)
// assert
assert.Error(t, err)
}
func TestParseDuration(t *testing.T) {
t.Parallel()
assert.Equal(t, "0:00", parseDuration(0))
assert.Equal(t, "0:40", parseDuration(40))
assert.Equal(t, "1:00", parseDuration(60))
assert.Equal(t, "1:40", parseDuration(100))
assert.Equal(t, "2:01", parseDuration(121))
assert.Equal(t, "59:59", parseDuration(3599))
assert.Equal(t, "1:00:00", parseDuration(3600))
assert.Equal(t, "1:00:01", parseDuration(3601))
assert.Equal(t, "1:01:00", parseDuration(3660))
assert.Equal(t, "1:01:03", parseDuration(3663))
assert.Equal(t, "10:00:00", parseDuration(36000))
assert.Equal(t, "10:00:01", parseDuration(36001))
assert.Equal(t, "10:01:00", parseDuration(36060))
assert.Equal(t, "10:01:03", parseDuration(36063))
}