Skip to content

Commit

Permalink
fix(tests): fixing tests for go<=1.22
Browse files Browse the repository at this point in the history
  • Loading branch information
samber committed Jan 25, 2025
1 parent 4914d99 commit c6bc5d3
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions oops_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"log/slog"
"net/http"
"runtime"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -48,8 +49,14 @@ func TestOopsWrap_wrapped(t *testing.T) {
req, _ := http.NewRequestWithContext(ctx, "GET", "https://google.com", nil)
_, err = Wrap2(http.DefaultClient.Do(req))
is.Error(err)
is.Equal("Get \"https://google.com\": hello timeout", err.(OopsError).err.Error())
is.Equal(map[string]any{"hello": "world"}, err.(OopsError).Context())

if runtime.Version() >= "go1.23" {
is.Equal("Get \"https://google.com\": hello timeout", err.(OopsError).err.Error())
is.Equal(map[string]any{"hello": "world"}, err.(OopsError).Context())
} else {
is.Equal("Get \"https://google.com\": context deadline exceeded", err.(OopsError).err.Error())
is.Equal(map[string]any{}, err.(OopsError).Context())
}
}

func TestOopsWrapf(t *testing.T) {
Expand Down

0 comments on commit c6bc5d3

Please sign in to comment.