Skip to content

Commit

Permalink
Add test for MustBlockInterceptor (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
at-wat authored Apr 21, 2021
1 parent 47d783c commit 4bf7a63
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion mkvcore/interceptor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ func BenchmarkMultiTrackBlockSorter(b *testing.B) {
}

func TestMultiTrackBlockSorter_FailingOptions(t *testing.T) {

errDummy := errors.New("an error")

cases := map[string]struct {
Expand Down Expand Up @@ -293,3 +292,31 @@ func TestMultiTrackBlockSorter_FailingOptions(t *testing.T) {
})
}
}

type dummyInterceptor struct{}

func (dummyInterceptor) Intercept([]BlockReader, []BlockWriter) {
panic("unimplemented")
}

func TestMustBlockInterceptor(t *testing.T) {
t.Run("OK", func(t *testing.T) {
i := &dummyInterceptor{}
ret := MustBlockInterceptor(i, nil)
if ret != i {
t.Error("MustBlockInterceptor must return the interceptor on success")
}
})
t.Run("Error", func(t *testing.T) {
i := &dummyInterceptor{}
err := errors.New("dummy error")

defer func() {
if r := recover(); r == nil {
t.Error("MustBlockInterceptor must panic on failure")
}
}()

_ = MustBlockInterceptor(i, err)
})
}

0 comments on commit 4bf7a63

Please sign in to comment.