Self review #1

Open
rob wants to merge 12 commits from dev into master
3 changed files with 14 additions and 14 deletions
Showing only changes of commit 7a294371b5 - Show all commits

View File

@ -7,16 +7,16 @@ import (
"net/http"
"os"
"segmento/pkg/media"
"segmento/pkg/playlist2"
"segmento/pkg/playlist"
)
type consumer struct{}
func (c *consumer) PlaylistSegmentAdded(p playlist2.Playlist, s *playlist2.PlaylistSegment) {
func (c *consumer) PlaylistSegmentAdded(p playlist.Playlist, s *playlist.PlaylistSegment) {
fmt.Println("in PlaylistSegmentAdded")
}
func (c *consumer) PlaylistUpdated(p playlist2.Playlist) {
func (c *consumer) PlaylistUpdated(p playlist.Playlist) {
fmt.Println("in PlaylistUpdated")
}
@ -50,7 +50,7 @@ func main() {
segmenter := media.NewMP3Segmenter()
publisher := &media.FakePublisher{}
playlist := playlist2.NewMediaPlaylist(resp.Body, segmenter, publisher)
playlist := playlist.NewMediaPlaylist(resp.Body, segmenter, publisher)
playlist.AddConsumer(&consumer{})
if err = playlist.Run(); err != nil {
log.Fatal(err)

View File

@ -1,4 +1,4 @@
package playlist2
package playlist
import (
"fmt"

View File

@ -1,9 +1,9 @@
package playlist2_test
package playlist_test
import (
"io"
"segmento/pkg/media"
"segmento/pkg/playlist2"
"segmento/pkg/playlist"
"strings"
"testing"
"time"
@ -51,21 +51,21 @@ type consumer struct {
pCount, sCount int
}
func (c *consumer) PlaylistUpdated(p playlist2.Playlist) {
func (c *consumer) PlaylistUpdated(p playlist.Playlist) {
c.pCount++
}
func (c *consumer) PlaylistSegmentAdded(p playlist2.Playlist, s *playlist2.PlaylistSegment) {
func (c *consumer) PlaylistSegmentAdded(p playlist.Playlist, s *playlist.PlaylistSegment) {
c.sCount++
}
func TestMediaPlaylistImplements(t *testing.T) {
require.Implements(t, (*playlist2.Playlist)(nil), new(playlist2.MediaPlaylist))
require.Implements(t, (*playlist.Playlist)(nil), new(playlist.MediaPlaylist))
}
func TestMediaPlaylist(t *testing.T) {
publisher := &FakeSegmentPublisher{}
playlist := playlist2.NewMediaPlaylist(&FakeReader{}, &FakeSegmenter{3}, publisher)
playlist := playlist.NewMediaPlaylist(&FakeReader{}, &FakeSegmenter{3}, publisher)
err := playlist.Run()
require.NoError(t, err)
@ -74,7 +74,7 @@ func TestMediaPlaylist(t *testing.T) {
}
func TestMediaPlaylistRender(t *testing.T) {
playlist := playlist2.NewMediaPlaylist(&FakeReader{}, &FakeSegmenter{2}, &FakeSegmentPublisher{})
playlist := playlist.NewMediaPlaylist(&FakeReader{}, &FakeSegmenter{2}, &FakeSegmentPublisher{})
err := playlist.Run()
require.NoError(t, err)
@ -91,9 +91,9 @@ func TestMediaPlaylistRender(t *testing.T) {
func TestMediaPlaylistConsumer(t *testing.T) {
consumer := &consumer{}
require.Implements(t, (*playlist2.Consumer)(nil), consumer)
require.Implements(t, (*playlist.Consumer)(nil), consumer)
playlist := playlist2.NewMediaPlaylist(&FakeReader{}, &FakeSegmenter{4}, &FakeSegmentPublisher{})
playlist := playlist.NewMediaPlaylist(&FakeReader{}, &FakeSegmenter{4}, &FakeSegmentPublisher{})
playlist.AddConsumer(consumer)
err := playlist.Run()
require.NoError(t, err)