Skip to content

Commit

Permalink
feat(problems): add test for problem error unwrap
Browse files Browse the repository at this point in the history
  • Loading branch information
ConsoleTVs committed Nov 17, 2024
1 parent 2d35ea2 commit da5e048
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions problem_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package akumu_test

import (
"encoding/json"
"errors"
"net/http"
"testing"

Expand Down Expand Up @@ -96,3 +97,22 @@ func TestCustomProblemHandler(t *testing.T) {
t.Fatalf("unexpected username: %s", username)
}
}

func TestProblemErrorUnwraps(t *testing.T) {
someErr := errors.New("some error")
someOtherErr := errors.New("some other error")
err := errors.Join(someErr, someOtherErr)
problem := akumu.NewProblem(err, http.StatusBadRequest)

if !errors.Is(problem, err) {
t.Fatalf("%s should be %s", problem, err)
}

if !errors.Is(problem, someErr) {
t.Fatalf("%s should be %s", problem, err)
}

if !errors.Is(problem, someOtherErr) {
t.Fatalf("%s should be %s", problem, err)
}
}

0 comments on commit da5e048

Please sign in to comment.