mirror of
https://github.com/lima-vm/lima.git
synced 2026-10-28 11:44:35 +08:00
pkg/must: add Must helper
Signed-off-by: varsha <varsha.narvi.07@gmail.com>
This commit is contained in:
1 parent
5a20c6d31d
commit
786ec58689
1 file changed
+25
@@ -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"))
|
||||
}
|
||||
Reference in new issue
Block a user