浏览文件
must_test.go
25 行 · 444 B历史下载| 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 | } |

