mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-06 04:20:11 +00:00
props did not have context, therefore they had no idea where they were or where to resolve from. Signed-off-by: quobix <dave@quobix.com>
37 lines
717 B
Go
37 lines
717 B
Go
// Copyright 2023 Princess B33f Heavy Industries / Dave Shanley
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package utils
|
|
|
|
import (
|
|
"errors"
|
|
"github.com/stretchr/testify/assert"
|
|
"testing"
|
|
)
|
|
|
|
func TestUnwrapErrors(t *testing.T) {
|
|
|
|
// create an array of errors
|
|
errs := []error{
|
|
errors.New("first error"),
|
|
errors.New("second error"),
|
|
errors.New("third error"),
|
|
}
|
|
|
|
// join them up
|
|
joined := errors.Join(errs...)
|
|
assert.Error(t, joined)
|
|
|
|
// unwrap them
|
|
unwrapped := UnwrapErrors(joined)
|
|
assert.Len(t, unwrapped, 3)
|
|
}
|
|
|
|
func TestUnwrapErrors_Empty(t *testing.T) {
|
|
assert.Len(t, UnwrapErrors(nil), 0)
|
|
}
|
|
|
|
func TestUnwrapErrors_SingleError(t *testing.T) {
|
|
assert.Len(t, UnwrapErrors(errors.New("single error")), 1)
|
|
}
|