2 // Copyright 2019 AT&T Intellectual Property
3 // Copyright 2019 Nokia
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
20 "github.com/stretchr/testify/assert"
24 func TestValidateAndBuildCellKeySuccess(t *testing.T) {
28 key, err := ValidateAndBuildCellIdKey(cellId)
30 t.Errorf("#utils_test.TestValidateAndBuildCellKey - failed to validate key parameter")
32 assert.Contains(t, key, cellId)
33 assert.Contains(t, key, delimiter)
34 assert.Contains(t, key, prefix)
37 func TestValidateAndBuildNodeBNameKeySuccess(t *testing.T) {
41 key, err := ValidateAndBuildNodeBNameKey(name)
43 t.Errorf("#utils_test.TestValidateAndBuildNodeBNameKey - failed to validate key parameter")
45 assert.Contains(t, key, name)
46 assert.Contains(t, key, delimiter)
47 assert.Contains(t, key, prefix)
50 func TestValidateAndBuildNodeBIdKeySuccess(t *testing.T) {
55 key, err := ValidateAndBuildNodeBIdKey(nodeType, plmnId, nbId)
57 t.Errorf("#utils_test.TestValidateAndBuildNodeBIdKey - failed to validate key parameter")
59 assert.Contains(t, key, nodeType)
60 assert.Contains(t, key, plmnId)
61 assert.Contains(t, key, nbId)
62 assert.Contains(t, key, delimiter)
65 func TestValidateAndBuildCellNamePciKeyNameValidationFailure(t *testing.T){
67 _, err := ValidateAndBuildCellNamePciKey("", uint32(pci))
69 assert.IsType(t, &ValidationError{}, err)
70 assert.Equal(t, "#utils.ValidateAndBuildCellNamePciKey - an empty inventory name received", err.Error())
73 func TestValidateAndBuildCellKeyCellidValidationFailure(t *testing.T) {
74 _, err := ValidateAndBuildCellIdKey("")
76 assert.IsType(t, &ValidationError{}, err)
77 assert.Equal(t, "#utils.ValidateAndBuildCellIdKey - an empty cell id received", err.Error())
80 func TestValidateAndBuildNodeBNameKeyNameValidationFailure(t *testing.T) {
81 _, err := ValidateAndBuildNodeBNameKey("")
83 assert.IsType(t, &ValidationError{}, err)
84 assert.Equal(t, "#utils.ValidateAndBuildNodeBNameKey - an empty inventory name received", err.Error())
87 func TestValidateAndBuildNodeBIdKeyNodeTypeValidationFailure(t *testing.T) {
90 _, err := ValidateAndBuildNodeBIdKey("", plmnId, nbId)
92 assert.IsType(t, &ValidationError{}, err)
93 assert.Equal(t, "#utils.ValidateAndBuildNodeBIdKey - an empty node type received", err.Error())
96 func TestValidateAndBuildNodeBIdKeyPlmnIdValidationFailure(t *testing.T) {
99 _, err := ValidateAndBuildNodeBIdKey(nodeType, "", nbId)
100 assert.NotNil(t, err)
101 assert.IsType(t, &ValidationError{}, err)
102 assert.Equal(t, "#utils.ValidateAndBuildNodeBIdKey - an empty plmnId received", err.Error())
105 func TestValidateAndBuildNodeBIdKeyNbIdValidationFailure(t *testing.T) {
108 _, err := ValidateAndBuildNodeBIdKey(nodeType, plmnId, "")
109 assert.NotNil(t, err)
110 assert.IsType(t, &ValidationError{}, err)
111 assert.Equal(t, "#utils.ValidateAndBuildNodeBIdKey - an empty nbId received", err.Error())
114 func TestValidateAndBuildCellNamePciKeySuccess(t *testing.T){
119 key, err := ValidateAndBuildCellNamePciKey(name, uint32(pci))
121 t.Errorf("#utils_test.TestValidateAndBuildCellNamePciKey - failed to validate key parameter")
123 assert.Contains(t, key, name)
124 assert.Contains(t, key, delimiter)
125 assert.Contains(t, key, prefix)
126 assert.Contains(t, key, "270f")
130 func TestValidateAndBuildRanLoadInformationKeySuccess(t *testing.T) {
134 key, err := ValidateAndBuildRanLoadInformationKey(name)
136 t.Errorf("#utils_test.TestValidateAndBuildRanLoadInformationKeySuccess - failed to validate key parameter")
138 assert.Contains(t, key, name)
139 assert.Contains(t, key, delimiter)
140 assert.Contains(t, key, prefix)
143 func TestValidateAndBuildRanLoadInformationKeyFailure(t *testing.T) {
145 _, err := ValidateAndBuildRanLoadInformationKey(name)
146 assert.NotNil(t, err)
147 assert.IsType(t, &ValidationError{}, err)