pkg/common/must_test.go   A
last analyzed

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 6
eloc 15
dl 0
loc 27
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A common_test.TestMustShouldNotPanicForNoErr 0 8 3
A common_test.TestMustShouldPanicOnErr 0 8 3
1
package common_test
2
3
import (
4
	"errors"
5
	"testing"
6
7
	"github.com/stefanoj3/dirstalk/pkg/common"
8
)
9
10
func TestMustShouldNotPanicForNoErr(t *testing.T) {
11
	defer func() {
12
		if r := recover(); r != nil {
13
			t.Fatal("no panic expected")
14
		}
15
	}()
16
17
	common.Must(nil)
18
}
19
20
func TestMustShouldPanicOnErr(t *testing.T) {
21
	defer func() {
22
		if r := recover(); r == nil {
23
			t.Fatal("panic expected")
24
		}
25
	}()
26
27
	common.Must(errors.New("my error"))
28
}
29