Skip to content

Commit a28905c

Browse files
authored
Merge pull request #4937 from varsha-0007/must-tests
test: add tests for pkg/must
2 parents 51876ba + 786ec58 commit a28905c

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

pkg/must/must_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// SPDX-FileCopyrightText: Copyright The Lima Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package must
5+
6+
import (
7+
"errors"
8+
"testing"
9+
10+
"gotest.tools/v3/assert"
11+
)
12+
13+
func TestMustSuccess(t *testing.T) {
14+
str := Must("string", nil)
15+
assert.Equal(t, str, "string")
16+
}
17+
18+
func TestMustPanic(t *testing.T) {
19+
defer func() {
20+
r := recover()
21+
assert.Assert(t, r != nil, "Must should have panicked")
22+
}()
23+
24+
Must("string", errors.New("test error"))
25+
}

0 commit comments

Comments
 (0)