Closed odeke-em closed 6 months ago
Kind /cc @aalexand @ghemawat
I sent https://github.com/google/pprof/pull/864 earlier today.
Oh cool, thanks @aalexand! Could we perhaps copy over and adapt the isolated test that I've crafted to prevent regressions?
func TestFetchDoesNotPanicOnMissingSource(t *testing.T) {
_, _, err := fetch("non-existent-source", 10*time.Millisecond, 10*time.Millisecond, nil, http.DefaultTransport)
if err == nil {
t.Fatal("expected a non-nil error")
}
if g, w := err, fs.ErrNotExist; !errors.Is(g, w) {
t.Fatalf("mismatched type: got %T, want %T", g, w)
}
}
Oh cool, thanks @aalexand! Could we perhaps copy over and adapt the isolated test that I've crafted to prevent regressions?
func TestFetchDoesNotPanicOnMissingSource(t *testing.T) { _, _, err := fetch("non-existent-source", 10*time.Millisecond, 10*time.Millisecond, nil, http.DefaultTransport) if err == nil { t.Fatal("expected a non-nil error") } if g, w := err, fs.ErrNotExist; !errors.Is(g, w) { t.Fatalf("mismatched type: got %T, want %T", g, w) } }
My PR added a test already.
Alright, thanks!
This change inverts checks to ensure that we return a wrapped fs.ErrNotExist error if we completely fail to find a source fetcher, instead of panicking.
Fixes #863