-
Notifications
You must be signed in to change notification settings - Fork 330
encode Segment.Map attribute #94
Conversation
Thanks, this looks good to me, would you be able to provide a unit test for it as well? Also, it appears we're reading Edit: If you need a hand, let me know. |
writer_test.go
Outdated
@@ -313,6 +313,7 @@ func TestSetMapForMediaPlaylist(t *testing.T) { | |||
if e != nil { | |||
t.Errorf("Set map to a media playlist failed: %s", e) | |||
} | |||
// fmt.Println(p.Encode().String()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're able to write the relevant tests, can you remove this comment?
writer_test.go
Outdated
@@ -566,7 +567,7 @@ func TestNewMasterPlaylistWithAlternatives(t *testing.T) { | |||
if m.ver != 4 { | |||
t.Fatalf("Expected version 4, actual, %d", m.ver) | |||
} | |||
fmt.Printf("%v\n", m) | |||
// fmt.Printf("%v\n", m) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're able to write the relevant tests, can you remove this comment?
2 similar comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm jumping the gun a bit here, but just saw you pushed some more commits.
This looks really good, appreciate the tests, extra coverage and updating of docs.
I noticed you didn't use raw string literals, they make the expected line a little easier to read, I'd suggest we swap them around (I've highlighted 2 cases but there's a few more) - I'll leave it to you to decide whether this was intentional or not and up to you if you want to leave it.
Let me know when you're ready and I'll merge.
writer_test.go
Outdated
} | ||
p.SetDefaultMap("https://example.com", 1000*1024, 1024*1024) | ||
|
||
expected := "EXT-X-MAP:URI=\"https://example.com\",BYTERANGE=1024000@1048576" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can rewrite with backticks so you don't need to escape the quotes, eg
expected := `#EXT-X-MAP:URI="https://example.com",BYTERANGE=1024000@1048576`
writer_test.go
Outdated
@@ -313,6 +328,43 @@ func TestSetMapForMediaPlaylist(t *testing.T) { | |||
if e != nil { | |||
t.Errorf("Set map to a media playlist failed: %s", e) | |||
} | |||
|
|||
expected := "EXT-X-MAP:URI=\"https://example.com\",BYTERANGE=1024000@1048576\n#EXTINF:5.000,\ntest01.ts" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively:
expected := `EXT-X-MAP:URI="https://example.com",BYTERANGE=1024000@1048576
#EXTINF:5.000,
test01.ts`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, have updated test expectations to string literals where possible. hopefully good to merge now.
Thanks for the contribution Andy and the additional tests. Much appreciated. |
Hi @grafov have added encoding for Segment.Map to address #93