Skip to content

Commit

Permalink
add specs for infoHandler error cases
Browse files Browse the repository at this point in the history
  • Loading branch information
ajatprabha committed Apr 15, 2024
1 parent f10ba45 commit d1c4690
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions otelcourier/info_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package otelcourier

import (
"context"
"net/http"
"os"
"os/signal"
"strconv"
Expand Down Expand Up @@ -112,3 +113,15 @@ func Test_boolInt64(t *testing.T) {
})
}
}

func TestInfoHandler_callback_error(t *testing.T) {
ih := infoHandler(func(w http.ResponseWriter, r *http.Request) {
_, _ = w.Write([]byte("invalid json"))
})

cb := ih.callback()
err := cb(context.Background(), nil)
assert.EqualError(t, err, "invalid character 'i' looking for beginning of value")

assert.EqualError(t, cb(nil, nil), "net/http: nil Context")
}

0 comments on commit d1c4690

Please sign in to comment.