blob: fcfe949c3147c6465f36fe24cc188643e1060854 [file] [log] [blame]
khenaidoobf6e7bb2018-08-14 22:27:29 -04001/*
2 * Copyright 2018-present Open Networking Foundation
3
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7
8 * http://www.apache.org/licenses/LICENSE-2.0
9
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Stephane Barbarie4a2564d2018-07-26 11:02:58 -040016package model
17
18import (
Stephane Barbarieec0919b2018-09-05 14:14:29 -040019 "github.com/opencord/voltha-go/protos/voltha"
Stephane Barbarie4a2564d2018-07-26 11:02:58 -040020 "reflect"
21 "testing"
22)
23
24/*
25
26 */
27func Test_ChildType_01_CacheIsEmpty(t *testing.T) {
28 if GetInstance().ChildrenFieldsCache != nil || len(GetInstance().ChildrenFieldsCache) > 0 {
29 t.Errorf("GetInstance().ChildrenFieldsCache should be empty: %+v\n", GetInstance().ChildrenFieldsCache)
30 }
31 t.Logf("GetInstance().ChildrenFieldsCache is empty - %+v\n", GetInstance().ChildrenFieldsCache)
32}
33
34/*
35
36 */
37func Test_ChildType_02_Device_Proto_ChildrenFields(t *testing.T) {
38
39 var cls *voltha.Device
40 //cls = &voltha.Device{Id:"testing-Config-rev-id"}
41
42 names := ChildrenFields(cls)
43
44 tst := reflect.ValueOf(cls).Elem().FieldByName("ImageDownloads")
45
Stephane Barbarie8c48b5c2018-10-02 09:45:17 -040046 t.Logf("############ Field by name : %+v\n", reflect.TypeOf(tst.Interface()))
Stephane Barbarie4a2564d2018-07-26 11:02:58 -040047
48 if names == nil || len(names) == 0 {
49 t.Errorf("ChildrenFields failed to return names: %+v\n", names)
50 }
51 t.Logf("ChildrenFields returned names: %+v\n", names)
52}
53
54/*
55
56 */
57func Test_ChildType_03_CacheHasOneEntry(t *testing.T) {
58 if GetInstance().ChildrenFieldsCache == nil || len(GetInstance().ChildrenFieldsCache) != 1 {
59 t.Errorf("GetInstance().ChildrenFieldsCache should have one entry: %+v\n", GetInstance().ChildrenFieldsCache)
60 }
61 t.Logf("GetInstance().ChildrenFieldsCache has one entry: %+v\n", GetInstance().ChildrenFieldsCache)
62}
63
64/*
65
66 */
67func Test_ChildType_04_ChildrenFieldsCache_Keys(t *testing.T) {
68 for k := range GetInstance().ChildrenFieldsCache {
69 t.Logf("GetInstance().ChildrenFieldsCache Key:%+v\n", k)
70 }
71}