In parseVariant(), we don't do much validation beyond type checking and parsing tokens before returning a Variant.
For example, Apple HLS authoring spec mentions that the CODECS attribute must be set for all variants.
There's some easy validation. After we've broken out of the loop reading items from the lexer, have a bunch of basic if statements checking stuff:
func parseVariant() {
var v Variant
for it := range items {
switch ... {
}
}
if v.Codecs == "" {
return nil, fmt.Errorf("codecs not set")
}
return v, nil
}
Not sure how to test this exactly. Two ways off the top of my head:
make a chan item and send items through it. Pass the chan to parseVariant().
decode simple playlists which have different "bad" variants in them.
However we do it, as long as it's easy to add new, readable test cases.
My first instinct is to go for option 2 as it feels clearer to have bad playlist specified as text as opposed to code with structs sent through channels.
In parseVariant(), we don't do much validation beyond type checking and parsing tokens before returning a Variant. For example, Apple HLS authoring spec mentions that the
CODECS
attribute must be set for all variants.There's some easy validation. After we've broken out of the loop reading items from the lexer, have a bunch of basic if statements checking stuff:
Not sure how to test this exactly. Two ways off the top of my head:
chan item
and send items through it. Pass the chan to parseVariant().However we do it, as long as it's easy to add new, readable test cases. My first instinct is to go for option 2 as it feels clearer to have bad playlist specified as text as opposed to code with structs sent through channels.