Skip to content
This repository was archived by the owner on Dec 8, 2024. It is now read-only.

Conversation

mbowBC
Copy link
Contributor

@mbowBC mbowBC commented Mar 2, 2017

No description provided.

@coveralls
Copy link

coveralls commented Mar 2, 2017

Coverage Status

Coverage decreased (-0.2%) to 58.845% when pulling 8201bad on mbowBC:ADD_CC_WRITE into f55aa7a on grafov:master.

@bradleyfalzon
Copy link
Collaborator

bradleyfalzon commented Mar 3, 2017

Would you be able to add reader support and tests?

EDIT: sorry, there is reader support already, but can you add a test for both reader and writer?

@coveralls
Copy link

coveralls commented Mar 3, 2017

Coverage Status

Coverage increased (+4.8%) to 63.78% when pulling 81e7f23 on mbowBC:ADD_CC_WRITE into f55aa7a on grafov:master.

@coveralls
Copy link

coveralls commented Mar 3, 2017

Coverage Status

Coverage increased (+4.8%) to 63.78% when pulling 5566280 on mbowBC:ADD_CC_WRITE into f55aa7a on grafov:master.

Copy link
Collaborator

@bradleyfalzon bradleyfalzon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the extra tests, I've added some feedback, we should be able to simplify some of these and still achieve a decent test.

reader_test.go Outdated
}

for i, v := range p.Variants {
//spew.Dump(p.Variants)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment can be removed

reader_test.go Outdated
if i == 0 && len(v.Alternatives) != 5 {
t.Fatalf("not all alternatives from #EXT-X-MEDIA parsed (has %d but should be 5", len(v.Alternatives))
}
if i > 0 && len(v.Alternatives) > 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neither of these if blocks belong here, looks like they were from the previous test testing Alternatives, feel free to just have the one if v.Captions ~!= ..., that's all you need to test for.

reader_test.go Outdated
@@ -96,7 +96,40 @@ func TestDecodeMasterPlaylistWithAlternatives(t *testing.T) {
t.Fatal("should not be alternatives for this variant")
}
}
// fmt.Println(p.Encode().String())
//fmt.Println(p.Encode().String())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line probably didn't need to be changed. We can remove it in another cleanup.

reader_test.go Outdated
t.Fatal("variant field for CLOSED-CAPTIONS should be equal to NONE but it equals", v.Captions)
}
}
//fmt.Println(p.Encode().String())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be removed, it appears to have just come from a copy/paste.

}

// Create new master playlist supporting closed-caption=none
func TestNewMasterPlaylistWithClosedCaptionEqNone(t *testing.T) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a very comprehensive test, but I don't think it really needs to be. Can the same writing test be achieved by just having a single master playlist, with one variant setting the Alternative Closed Captions to none?

And then the test can be a straight forward strings.Contains, such as

m3u8/writer_test.go

Lines 192 to 221 in f55aa7a

func TestSetSCTEForMediaPlaylist(t *testing.T) {
tests := []struct {
Cue string
ID string
Time float64
Expected string
}{
{"CueData1", "", 0, `#EXT-SCTE35:CUE="CueData1"` + "\n"},
{"CueData2", "ID2", 0, `#EXT-SCTE35:CUE="CueData2",ID="ID2"` + "\n"},
{"CueData3", "ID3", 3.141, `#EXT-SCTE35:CUE="CueData3",ID="ID3",TIME=3.141` + "\n"},
{"CueData4", "", 3.1, `#EXT-SCTE35:CUE="CueData4",TIME=3.1` + "\n"},
{"CueData5", "", 3.0, `#EXT-SCTE35:CUE="CueData5",TIME=3` + "\n"},
}
for _, test := range tests {
p, e := NewMediaPlaylist(1, 1)
if e != nil {
t.Fatalf("Create media playlist failed: %s", e)
}
if e = p.Append("test01.ts", 5.0, ""); e != nil {
t.Errorf("Add 1st segment to a media playlist failed: %s", e)
}
if e := p.SetSCTE(test.Cue, test.ID, test.Time); e != nil {
t.Errorf("SetSCTE to a media playlist failed: %s", e)
}
if !strings.Contains(p.String(), test.Expected) {
t.Errorf("Test %+v did not contain: %q, playlist: %v", test, test.Expected, p.String())
}
}
}
?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok will do.

writer_test.go Outdated
if m.ver != 4 {
t.Fatalf("Expected version 4, actual, %d", m.ver)
}
// diff with master file using reader.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment on test, but I don't think this test needs to be any more complicated than a strings.Contains.

If we do want this comprehensive test (@grafov thoughts?), then this test should be renamed to something like TestNewMasterPlaylistWithAlternates and a simpler string comparison should be made instead of bringing in difflib.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think as the library code is simple and doesn't need external deps so the tests should avoid external deps too.

@coveralls
Copy link

coveralls commented Mar 6, 2017

Coverage Status

Coverage increased (+6.2%) to 65.205% when pulling e4e2dd5 on mbowBC:ADD_CC_WRITE into f55aa7a on grafov:master.

@coveralls
Copy link

coveralls commented Mar 6, 2017

Coverage Status

Coverage increased (+6.0%) to 65.019% when pulling 796b493 on mbowBC:ADD_CC_WRITE into f55aa7a on grafov:master.

@coveralls
Copy link

coveralls commented Mar 6, 2017

Coverage Status

Coverage increased (+6.0%) to 65.019% when pulling bc89f66 on mbowBC:ADD_CC_WRITE into f55aa7a on grafov:master.

@bradleyfalzon
Copy link
Collaborator

I can see more commits, and they're looking good, but you haven't stated you're finished, so I'll await your confirmation before reviewing.

@mbowBC
Copy link
Contributor Author

mbowBC commented Mar 6, 2017

I think that's it, let me know if I've missed anything.

writer_test.go Outdated
// Create new master playlist supporting closed-caption=none
func TestNewMasterPlaylistWithClosedCaptionEqNone(t *testing.T) {
m := NewMasterPlaylist()
var alts = []*Alternative{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more thing, is this still required? If it's just to test for captions == none, I don't think we need an alternative for it? I'm not familiar with alternative or captions myself in m3u8 spec, so if an Alternative is required to set Captions to none then I'm OK with leaving it in, but if it's not required, then I think we can remove this from here too.

@bradleyfalzon
Copy link
Collaborator

This is fine, one minor comment, but then I think we can merge.

@mbowBC
Copy link
Contributor Author

mbowBC commented Mar 7, 2017

Thanks yes looks like don't need set up Alts, so have removed it.

@coveralls
Copy link

coveralls commented Mar 7, 2017

Coverage Status

Coverage increased (+6.0%) to 65.019% when pulling 4d17293 on mbowBC:ADD_CC_WRITE into f55aa7a on grafov:master.

@bradleyfalzon
Copy link
Collaborator

You're a champion, thanks for the time, looks good to me but the CI failure seems to be a gofmt issue, did you not have a chance to run that - could you?

@coveralls
Copy link

coveralls commented Mar 7, 2017

Coverage Status

Coverage increased (+6.0%) to 65.019% when pulling 1febd27 on mbowBC:ADD_CC_WRITE into f55aa7a on grafov:master.

@mbowBC
Copy link
Contributor Author

mbowBC commented Mar 7, 2017

apologies no idea why Gogland IDE didn't do that, cli way works fine.

@bradleyfalzon bradleyfalzon merged commit e521730 into grafov:master Mar 7, 2017
@bradleyfalzon
Copy link
Collaborator

Thanks for the contribution @mbowBC

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants