blob: 6996a6d2eaac8be0fbdf1bee264fd9d4447b29d0 [file] [log] [blame]
Stephane Barbarie4a2564d2018-07-26 11:02:58 -04001package model
2
3import (
4 "fmt"
5 "github.com/opencord/voltha/protos/go/voltha"
6 "reflect"
7 "testing"
8)
9
10/*
11
12 */
13func Test_ChildType_01_CacheIsEmpty(t *testing.T) {
14 if GetInstance().ChildrenFieldsCache != nil || len(GetInstance().ChildrenFieldsCache) > 0 {
15 t.Errorf("GetInstance().ChildrenFieldsCache should be empty: %+v\n", GetInstance().ChildrenFieldsCache)
16 }
17 t.Logf("GetInstance().ChildrenFieldsCache is empty - %+v\n", GetInstance().ChildrenFieldsCache)
18}
19
20/*
21
22 */
23func Test_ChildType_02_Device_Proto_ChildrenFields(t *testing.T) {
24
25 var cls *voltha.Device
26 //cls = &voltha.Device{Id:"testing-Config-rev-id"}
27
28 names := ChildrenFields(cls)
29
30 tst := reflect.ValueOf(cls).Elem().FieldByName("ImageDownloads")
31
32 fmt.Printf("############ Field by name : %+v\n", reflect.TypeOf(tst.Interface()))
33
34 if names == nil || len(names) == 0 {
35 t.Errorf("ChildrenFields failed to return names: %+v\n", names)
36 }
37 t.Logf("ChildrenFields returned names: %+v\n", names)
38}
39
40/*
41
42 */
43func Test_ChildType_03_CacheHasOneEntry(t *testing.T) {
44 if GetInstance().ChildrenFieldsCache == nil || len(GetInstance().ChildrenFieldsCache) != 1 {
45 t.Errorf("GetInstance().ChildrenFieldsCache should have one entry: %+v\n", GetInstance().ChildrenFieldsCache)
46 }
47 t.Logf("GetInstance().ChildrenFieldsCache has one entry: %+v\n", GetInstance().ChildrenFieldsCache)
48}
49
50/*
51
52 */
53func Test_ChildType_04_ChildrenFieldsCache_Keys(t *testing.T) {
54 for k := range GetInstance().ChildrenFieldsCache {
55 t.Logf("GetInstance().ChildrenFieldsCache Key:%+v\n", k)
56 }
57}