diff options
| author | mo khan <mo@mokhan.ca> | 2022-05-15 21:03:49 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2022-05-15 21:03:49 -0600 |
| commit | 9efaef650d60340e4e5f45ed1f2b847b64c616c4 (patch) | |
| tree | 9f1b15a0fe0ce5ad8909ca83718fb306fd54cd74 /pkg/x/must_test.go | |
| parent | 6e926d60f2a66021dac431fd03add4796eb2e803 (diff) | |
Diffstat (limited to 'pkg/x/must_test.go')
| -rw-r--r-- | pkg/x/must_test.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/pkg/x/must_test.go b/pkg/x/must_test.go new file mode 100644 index 0000000..a571beb --- /dev/null +++ b/pkg/x/must_test.go @@ -0,0 +1,24 @@ +package x + +import ( + "errors" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestMust(t *testing.T) { + t.Run("without error", func(t *testing.T) { + item := 1 + result := Must(item, nil) + assert.Equal(t, item, result) + }) + + t.Run("with error", func(t *testing.T) { + assert.Panics(t, func() { + item := 1 + result := Must(item, errors.New("darn")) + assert.Equal(t, item, result) + }) + }) +} |
