forked from viamrobotics/rdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherrors_test.go
50 lines (41 loc) · 1.17 KB
/
errors_test.go
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
44
45
46
47
48
49
50
package resource
import (
"testing"
"go.viam.com/test"
)
func TestDependencyTypeError(t *testing.T) {
name := NewName(APINamespace("foo").WithType("bar").WithSubtype("baz"), "bark")
test.That(t,
DependencyTypeError[someRes1](name, someRes2{}).Error(),
test.ShouldContainSubstring,
`dependency "foo:bar:baz/bark" should be an implementation of resource.someRes1 but it was a resource.someRes2`,
)
test.That(t,
DependencyTypeError[someIfc](name, someRes2{}).Error(),
test.ShouldContainSubstring,
`dependency "foo:bar:baz/bark" should be an implementation of resource.someIfc but it was a resource.someRes2`,
)
}
func TestTypeError(t *testing.T) {
test.That(t,
TypeError[someRes1](someRes2{}).Error(),
test.ShouldContainSubstring,
"expected implementation of resource.someRes1 but it was a resource.someRes2",
)
test.That(t,
TypeError[someIfc](someRes2{}).Error(),
test.ShouldContainSubstring,
"expected implementation of resource.someIfc but it was a resource.someRes2",
)
}
type someIfc Resource
type someRes1 struct {
Named
TriviallyReconfigurable
TriviallyCloseable
}
type someRes2 struct {
Named
TriviallyReconfigurable
TriviallyCloseable
}