From cb5e49825498b97dbefeb699f196f40e20989e7b Mon Sep 17 00:00:00 2001 From: quobix Date: Wed, 1 Nov 2023 14:45:20 -0400 Subject: [PATCH] is this the one to make it green? Signed-off-by: quobix --- utils/unwrap_errors_test.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 utils/unwrap_errors_test.go diff --git a/utils/unwrap_errors_test.go b/utils/unwrap_errors_test.go new file mode 100644 index 0000000..08929bb --- /dev/null +++ b/utils/unwrap_errors_test.go @@ -0,0 +1,32 @@ +// 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) +}