-
Notifications
You must be signed in to change notification settings - Fork 174
Expand file tree
/
Copy pathutil_test.go
More file actions
28 lines (24 loc) · 869 Bytes
/
util_test.go
File metadata and controls
28 lines (24 loc) · 869 Bytes
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
package dresources
import (
"reflect"
"testing"
"github.com/stretchr/testify/assert"
)
// assertFieldsCovered asserts that all fields in sdkType (except those in skip)
// are present as direct fields in remoteType, and that skipped fields are indeed absent.
func assertFieldsCovered(t *testing.T, sdkType, remoteType reflect.Type, skip map[string]bool) {
t.Helper()
remoteFields := map[string]bool{}
for f := range remoteType.Fields() {
if !f.Anonymous {
remoteFields[f.Name] = true
}
}
for field := range sdkType.Fields() {
if skip[field.Name] {
assert.NotContains(t, remoteFields, field.Name, "field %s is in skip list but present in %s; remove it from skip", field.Name, remoteType.Name())
continue
}
assert.Contains(t, remoteFields, field.Name, "field %s from %s is missing in %s", field.Name, sdkType.Name(), remoteType.Name())
}
}