summaryrefslogtreecommitdiff
path: root/pkg/x/must_test.go
blob: a571beb7227af1a79ff8bfde3e8ded7dc480ed51 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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)
		})
	})
}