-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patherror_test.go
More file actions
43 lines (32 loc) · 1.26 KB
/
Copy patherror_test.go
File metadata and controls
43 lines (32 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package hime
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestErrors(t *testing.T) {
t.Parallel()
var err error
err = newErrRouteNotFound("route123")
assert.IsType(t, &ErrRouteNotFound{}, err)
assert.Contains(t, err.Error(), "route123")
err = newErrTemplateDuplicate("temp123")
assert.IsType(t, &ErrTemplateDuplicate{}, err)
assert.Contains(t, err.Error(), "temp123")
err = newErrTemplateNotFound("temp123")
assert.IsType(t, &ErrTemplateNotFound{}, err)
assert.Contains(t, err.Error(), "temp123")
}
func TestErrorMessages(t *testing.T) {
t.Parallel()
assert.Equal(t, "hime: route 'r' not found", newErrRouteNotFound("r").Error())
assert.Equal(t, "hime: template 't' not found", newErrTemplateNotFound("t").Error())
assert.Equal(t, "hime: template 't' already exists", newErrTemplateDuplicate("t").Error())
assert.Equal(t, "hime: component 'c' not found", newErrComponentNotFound("c").Error())
assert.Equal(t, "hime: component 'c' already exists", newErrComponentDuplicate("c").Error())
assert.Equal(t, "hime: app not found", ErrAppNotFound.Error())
}
func TestPanicf(t *testing.T) {
t.Parallel()
// panicf prefixes "hime: " and formats the message.
assert.PanicsWithValue(t, "hime: bad value 42", func() { panicf("bad value %d", 42) })
}