File: timeItem_test.go

package info (click to toggle)
golang-github-etherlabsio-go-m3u8 1.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 348 kB
  • sloc: makefile: 3
file content (29 lines) | stat: -rw-r--r-- 648 bytes parent folder | download | duplicates (2)
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
package test

import (
	"testing"
	"time"

	"github.com/etherlabsio/go-m3u8/m3u8"
	"github.com/stretchr/testify/assert"
)

func TestTimeItem_New(t *testing.T) {
	timeVar, err := m3u8.ParseTime("2010-02-19T14:54:23.031Z")
	assert.Nil(t, err)
	ti := &m3u8.TimeItem{
		Time: timeVar,
	}

	assert.Equal(t, "#EXT-X-PROGRAM-DATE-TIME:2010-02-19T14:54:23.031Z", ti.String())
}

func TestTimeItem_Parse(t *testing.T) {
	ti, err := m3u8.NewTimeItem("#EXT-X-PROGRAM-DATE-TIME:2010-02-19T14:54:23.031Z")
	assert.Nil(t, err)

	expected, err := time.Parse(time.RFC3339Nano, "2010-02-19T14:54:23.031Z")
	assert.Nil(t, err)

	assert.Equal(t, expected, ti.Time)
}