VOL-2726 Changed all usages of childTypesSingleton to use the provided getters and setters.
This makes map access thread-safe.
Change-Id: I5cc1c6fa5c074c3020a1e1e37e88d2456f81ad7f
diff --git a/db/model/child_type_test.go b/db/model/child_type_test.go
index 5a64264..b57d988 100644
--- a/db/model/child_type_test.go
+++ b/db/model/child_type_test.go
@@ -39,10 +39,13 @@
// Verify that the cache contains an entry for types on which ChildrenFields was performed
func TestChildType_02_Cache_Keys(t *testing.T) {
- if _, exists := getChildTypes().Cache[reflect.TypeOf(&voltha.Device{}).String()]; !exists {
- t.Errorf("getChildTypeCache().Cache should have an entry of type: %+v\n", reflect.TypeOf(&voltha.Device{}).String())
+ childTypes.mutex.RLock()
+ defer childTypes.mutex.RUnlock()
+
+ if _, exists := childTypes.cache[reflect.TypeOf(&voltha.Device{})]; !exists {
+ t.Errorf("childTypes.cache should have an entry of type: %+v\n", reflect.TypeOf(&voltha.Device{}).String())
}
- for k := range getChildTypes().Cache {
- t.Logf("getChildTypeCache().Cache Key:%+v\n", k)
+ for k := range childTypes.cache {
+ t.Logf("childTypes.cache Key:%+v\n", k)
}
}