pkg/must: add Must helper

Signed-off-by: varsha <varsha.narvi.07@gmail.com>
This commit is contained in:
varsha committed 2026-05-11 12:17:12 +05:30
1 parent 5a20c6d31d
commit 786ec58689
1 file changed
+25
+25
View File
@@ -0,0 +1,25 @@
// SPDX-FileCopyrightText: Copyright The Lima Authors
// SPDX-License-Identifier: Apache-2.0
package must
import (
"errors"
"testing"
"gotest.tools/v3/assert"
)
func TestMustSuccess(t *testing.T) {
str := Must("string", nil)
assert.Equal(t, str, "string")
}
func TestMustPanic(t *testing.T) {
defer func() {
r := recover()
assert.Assert(t, r != nil, "Must should have panicked")
}()
Must("string", errors.New("test error"))
}