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

View File

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

View File

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