Skip to content

Commit

Permalink
fix lint errors, simplify tests (#164)
Browse files Browse the repository at this point in the history
  • Loading branch information
aler9 authored Jun 10, 2024
1 parent 8506915 commit bc060a2
Showing 1 changed file with 4 additions and 22 deletions.
26 changes: 4 additions & 22 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,8 @@ func TestClient(t *testing.T) {
t.Run(mode+"_"+format, func(t *testing.T) {
httpServ := &http.Server{
Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// reject requests that do not have out custom header - key pair to ensure OnRequest was called
if r.Header.Get(testHeaderKey) != testHeaderValue {
w.WriteHeader(http.StatusUnauthorized)
return
}
require.Equal(t, testHeaderValue, r.Header.Get(testHeaderKey))

if format == "mpegts" {
switch {
case r.Method == http.MethodGet && r.URL.Path == "/stream.m3u8":
Expand Down Expand Up @@ -489,23 +486,8 @@ func TestClient(t *testing.T) {
err = c.Start()
require.NoError(t, err)

// loop the channels with a select so we can catch the error if something fails
// for example if you get a 401 then we need to handle it
for {
exit := false
select {
case <-videoRecv:
continue
case <-audioRecv:
continue
case err := <-c.Wait():
require.Equal(t, ErrClientEOS, err)
exit = true
}
if exit {
break
}
}
<-videoRecv
<-audioRecv

c.Close()
})
Expand Down

0 comments on commit bc060a2

Please sign in to comment.