Added unit tests in config

This commit is contained in:
nickolasdaniel
2021-05-24 14:57:13 +03:00
committed by Dan Christian Bogos
parent d72327cbb5
commit b14555924a
7 changed files with 587 additions and 2 deletions

View File

@@ -660,7 +660,7 @@ func prepareSectionFromMap(section string, mp interface{}) (cfgSec interface{},
case GeneralJSON:
cfgSec = new(GeneralJsonCfg)
case RPCConnsJSON:
cfgSec = make(RPCConnsJson)
cfgSec = &RPCConnsJson{}
case CacheJSON:
cfgSec = new(CacheJsonCfg)
case ListenJSON:
@@ -730,7 +730,7 @@ func prepareSectionFromMap(section string, mp interface{}) (cfgSec interface{},
case SIPAgentJSON:
cfgSec = new(SIPAgentJsonCfg)
case TemplatesJSON:
cfgSec = make(FcTemplatesJsonCfg)
cfgSec = &FcTemplatesJsonCfg{}
case ConfigSJSON:
cfgSec = new(ConfigSCfgJson)
case APIBanJSON:

249
config/config_apis_test.go Normal file
View File

@@ -0,0 +1,249 @@
/*
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
Copyright (C) ITsysCOM GmbH
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package config
import (
"reflect"
"testing"
"github.com/cgrates/cgrates/utils"
)
func TestPrepareGeneralSectionFromMap(t *testing.T) {
section := GeneralJSON
mp := map[string]interface{}{
"Node_id": "",
"Logger": "*syslog",
"Log_level": 7,
"Rounding_decimals": 5,
"Dbdata_encoding": "*msgpack",
"Tpexport_dir": "/var/spool/cgrates/tpe",
"Poster_attempts": 3,
"Failed_posts_dir": "/var/spool/cgrates/failed_posts",
"Failed_posts_ttl": "5s",
"Default_request_type": "*rated",
"Default_category": "call",
"Default_tenant": "cgrates.org",
"Default_timezone": "Local",
"Default_caching": "*reload",
"Min_call_duration": "0s",
"Max_call_duration": "3h",
"Connect_attempts": 5,
"Reconnects": -1,
"Connect_timeout": "1s",
"Reply_timeout": "2s",
"Locking_timeout": "0",
"Digest_separator": ",",
"Digest_equal": ":",
"Rsr_separator": ";",
"Max_parallel_conns": 100,
}
expected := &GeneralJsonCfg{
Node_id: utils.StringPointer(""),
Logger: utils.StringPointer("*syslog"),
Log_level: utils.IntPointer(7),
Rounding_decimals: utils.IntPointer(5),
Dbdata_encoding: utils.StringPointer("*msgpack"),
Tpexport_dir: utils.StringPointer("/var/spool/cgrates/tpe"),
Poster_attempts: utils.IntPointer(3),
Failed_posts_dir: utils.StringPointer("/var/spool/cgrates/failed_posts"),
Failed_posts_ttl: utils.StringPointer("5s"),
Default_request_type: utils.StringPointer("*rated"),
Default_category: utils.StringPointer("call"),
Default_tenant: utils.StringPointer("cgrates.org"),
Default_timezone: utils.StringPointer("Local"),
Default_caching: utils.StringPointer("*reload"),
Connect_attempts: utils.IntPointer(5),
Reconnects: utils.IntPointer(-1),
Connect_timeout: utils.StringPointer("1s"),
Reply_timeout: utils.StringPointer("2s"),
Locking_timeout: utils.StringPointer("0"),
Digest_separator: utils.StringPointer(","),
Digest_equal: utils.StringPointer(":"),
Rsr_separator: utils.StringPointer(";"),
Max_parallel_conns: utils.IntPointer(100),
}
if cfgSec, err := prepareSectionFromMap(section, mp); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(cfgSec, expected) {
t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(mp), utils.ToJSON(cfgSec))
}
}
func TestPrepareCacheSectionFromMap(t *testing.T) {
section := CacheJSON
mp := &CacheJsonCfg{
Partitions: map[string]*CacheParamJsonCfg{
"*resource_profiles": {
Limit: utils.IntPointer(-1),
Ttl: utils.StringPointer(""),
Static_ttl: utils.BoolPointer(false),
Precache: utils.BoolPointer(false),
Replicate: utils.BoolPointer(false),
},
},
}
expected := &CacheJsonCfg{
Partitions: map[string]*CacheParamJsonCfg{
"*resource_profiles": {
Limit: utils.IntPointer(-1),
Ttl: utils.StringPointer(""),
Static_ttl: utils.BoolPointer(false),
Precache: utils.BoolPointer(false),
Replicate: utils.BoolPointer(false),
},
},
}
if cfgSec, err := prepareSectionFromMap(section, mp); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(cfgSec, expected) {
t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(mp), utils.ToJSON(cfgSec))
}
}
func TestPrepareListenSectionFromMap(t *testing.T) {
section := ListenJSON
mp := &ListenJsonCfg{
Rpc_json: utils.StringPointer("127.0.0.1:2012"),
Rpc_gob: utils.StringPointer("127.0.0.1:2013"),
Http: utils.StringPointer("127.0.0.1:2080"),
Rpc_json_tls: utils.StringPointer("127.0.0.1:2023"),
Http_tls: utils.StringPointer("127.0.0.1:2280"),
}
expected := &ListenJsonCfg{
Rpc_json: utils.StringPointer("127.0.0.1:2012"),
Rpc_gob: utils.StringPointer("127.0.0.1:2013"),
Http: utils.StringPointer("127.0.0.1:2080"),
Rpc_json_tls: utils.StringPointer("127.0.0.1:2023"),
Http_tls: utils.StringPointer("127.0.0.1:2280"),
}
if cfgSec, err := prepareSectionFromMap(section, mp); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(cfgSec, expected) {
t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(mp), utils.ToJSON(cfgSec))
}
}
func TestPrepareHTTPSectionFromMap(t *testing.T) {
section := HTTPJSON
mp := &HTTPJsonCfg{
Json_rpc_url: utils.StringPointer("/jsonrpc"),
Registrars_url: utils.StringPointer("/registrar"),
Ws_url: utils.StringPointer("/ws"),
Freeswitch_cdrs_url: utils.StringPointer("/freeswitch_json"),
Http_Cdrs: utils.StringPointer("/cdr_http"),
Use_basic_auth: utils.BoolPointer(false),
Auth_users: &map[string]string{
"user1": "pass1",
},
Client_opts: map[string]interface{}{},
}
expected := &HTTPJsonCfg{
Json_rpc_url: utils.StringPointer("/jsonrpc"),
Registrars_url: utils.StringPointer("/registrar"),
Ws_url: utils.StringPointer("/ws"),
Freeswitch_cdrs_url: utils.StringPointer("/freeswitch_json"),
Http_Cdrs: utils.StringPointer("/cdr_http"),
Use_basic_auth: utils.BoolPointer(false),
Auth_users: &map[string]string{
"user1": "pass1",
},
Client_opts: map[string]interface{}{},
}
if cfgSec, err := prepareSectionFromMap(section, mp); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(cfgSec, expected) {
t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(mp), utils.ToJSON(cfgSec))
}
}
func TestPrepareStorDBSectionFromMap(t *testing.T) {
section := StorDBJSON
mp := map[string]interface{}{
"db_type": "*mysql",
"db_host": "127.0.0.1",
"db_port": 3306,
"db_name": "cgrates",
"db_user": "cgrates",
"db_password": "",
"string_indexed_fields": []string{},
"prefix_indexed_fields": []string{},
"opts": map[string]interface{}{},
"items": map[string]*ItemOptJson{},
}
expected := &DbJsonCfg{
Db_type: utils.StringPointer("*mysql"),
Db_host: utils.StringPointer("127.0.0.1"),
Db_port: utils.IntPointer(3306),
Db_name: utils.StringPointer("cgrates"),
Db_user: utils.StringPointer("cgrates"),
Db_password: utils.StringPointer(""),
String_indexed_fields: &[]string{},
Prefix_indexed_fields: &[]string{},
Opts: map[string]interface{}{},
Items: map[string]*ItemOptJson{},
}
if cfgSec, err := prepareSectionFromMap(section, mp); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(cfgSec, expected) {
t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(mp), utils.ToJSON(cfgSec))
}
}
func TestPrepareDataDBSectionFromMap(t *testing.T) {
section := DataDBJSON
mp := &DbJsonCfg{
Db_type: utils.StringPointer("*mysql"),
Db_host: utils.StringPointer("127.0.0.1"),
Db_port: utils.IntPointer(3306),
Db_name: utils.StringPointer("cgrates"),
Db_user: utils.StringPointer("cgrates"),
Db_password: utils.StringPointer(""),
String_indexed_fields: &[]string{},
Prefix_indexed_fields: &[]string{},
Opts: map[string]interface{}{},
Items: map[string]*ItemOptJson{},
}
expected := &DbJsonCfg{
Db_type: utils.StringPointer("*mysql"),
Db_host: utils.StringPointer("127.0.0.1"),
Db_port: utils.IntPointer(3306),
Db_name: utils.StringPointer("cgrates"),
Db_user: utils.StringPointer("cgrates"),
Db_password: utils.StringPointer(""),
String_indexed_fields: &[]string{},
Prefix_indexed_fields: &[]string{},
Opts: map[string]interface{}{},
Items: map[string]*ItemOptJson{},
}
if cfgSec, err := prepareSectionFromMap(section, mp); err != nil {
t.Error(err)
} else if !reflect.DeepEqual(cfgSec, expected) {
t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(mp), utils.ToJSON(cfgSec))
}
}

View File

@@ -833,6 +833,19 @@ func TestDiffEventExporterJsonCfg(t *testing.T) {
if !reflect.DeepEqual(rcv, expected) {
t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(expected), utils.ToJSON(rcv))
}
d = &EventExporterJsonCfg{
Fields: &[]*FcTemplateJsonCfg{
{
Type: utils.StringPointer("*prefix"),
},
},
}
rcv = diffEventExporterJsonCfg(d, v1, v2, ";")
if !reflect.DeepEqual(rcv, expected) {
t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(expected), utils.ToJSON(rcv))
}
}
func TestGetEventExporterJsonCfg(t *testing.T) {
@@ -1020,6 +1033,17 @@ func TestDiffEventExportersJsonCfg(t *testing.T) {
if !reflect.DeepEqual(rcv, expected) {
t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(expected), utils.ToJSON(rcv))
}
d = &[]*EventExporterJsonCfg{
{
Id: utils.StringPointer("EES_ID2"),
},
}
rcv = diffEventExportersJsonCfg(d, v1, v2, ";")
if !reflect.DeepEqual(rcv, expected) {
t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(expected), utils.ToJSON(rcv))
}
}
func TestDiffEEsJsonCfg(t *testing.T) {

View File

@@ -630,3 +630,109 @@ func TestGetHttpAgentCfg(t *testing.T) {
t.Errorf("Expected %v \n but received \n %v", expected, rcv)
}
}
func TestDiffHttpAgentJson(t *testing.T) {
var d *HttpAgentJsonCfg
v1 := &HTTPAgentCfg{
ID: "http_agent",
URL: "http_url",
SessionSConns: []string{"*localhost"},
RequestPayload: "request_payload",
ReplyPayload: "reply_payload",
RequestProcessors: []*RequestProcessor{
{
ID: "req_processors",
},
},
}
v2 := &HTTPAgentCfg{
ID: "http_agent2",
URL: "http_url2",
SessionSConns: []string{"*birpc"},
RequestPayload: "request_payload2",
ReplyPayload: "reply_payload2",
RequestProcessors: []*RequestProcessor{},
}
expected := &HttpAgentJsonCfg{
Id: utils.StringPointer("http_agent2"),
Url: utils.StringPointer("http_url2"),
Sessions_conns: &[]string{"*birpc"},
Request_payload: utils.StringPointer("request_payload2"),
Reply_payload: utils.StringPointer("reply_payload2"),
Request_processors: &[]*ReqProcessorJsnCfg{},
}
rcv := diffHttpAgentJsonCfg(d, v1, v2, ";")
if !reflect.DeepEqual(rcv, expected) {
t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(expected), utils.ToJSON(rcv))
}
v1 = v2
expected = &HttpAgentJsonCfg{
Request_processors: &[]*ReqProcessorJsnCfg{},
}
rcv = diffHttpAgentJsonCfg(d, v1, v2, ";")
if !reflect.DeepEqual(rcv, expected) {
t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(expected), utils.ToJSON(rcv))
}
}
func TestDiffHttpAgentsJsonCfg(t *testing.T) {
var d *[]*HttpAgentJsonCfg
v1 := HTTPAgentCfgs{
{
ID: "http_agent",
URL: "http_url",
SessionSConns: []string{"*localhost"},
RequestPayload: "request_payload",
ReplyPayload: "reply_payload",
RequestProcessors: []*RequestProcessor{
{
ID: "req_processors",
},
},
},
}
v2 := HTTPAgentCfgs{
{
ID: "http_agent2",
URL: "http_url2",
SessionSConns: []string{"*birpc"},
RequestPayload: "request_payload2",
ReplyPayload: "reply_payload2",
RequestProcessors: []*RequestProcessor{},
},
}
expected := &[]*HttpAgentJsonCfg{
{
Id: utils.StringPointer("http_agent2"),
Url: utils.StringPointer("http_url2"),
Sessions_conns: &[]string{"*birpc"},
Request_payload: utils.StringPointer("request_payload2"),
Reply_payload: utils.StringPointer("reply_payload2"),
Request_processors: &[]*ReqProcessorJsnCfg{},
},
}
rcv := diffHttpAgentsJsonCfg(d, v1, v2, ";")
if !reflect.DeepEqual(rcv, expected) {
t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(expected), utils.ToJSON(rcv))
}
d = &[]*HttpAgentJsonCfg{
{
Id: utils.StringPointer("http_agent2"),
},
}
rcv = diffHttpAgentsJsonCfg(d, v1, v2, ";")
if !reflect.DeepEqual(rcv, expected) {
t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(expected), utils.ToJSON(rcv))
}
}

View File

@@ -378,3 +378,116 @@ func TestSureTaxCfgClone(t *testing.T) {
t.Errorf("Expected: %+v\nReceived: %+v", utils.ToJSON(ban), utils.ToJSON(rcv))
}
}
func TestDiffSureTaxJson(t *testing.T) {
var d *SureTaxJsonCfg
// tLocal, err := time.LoadLocation("UTC")
// if err != nil {
// t.Error(err)
// }
v1 := &SureTaxCfg{
URL: "randomURL2",
ClientNumber: "randomClient2",
ValidationKey: "randomKey2",
BusinessUnit: "randomUnit2",
Timezone: &time.Location{},
IncludeLocalCost: false,
ReturnFileCode: "2",
ResponseGroup: "07",
ResponseType: "A4",
RegulatoryCode: "07",
ClientTracking: NewRSRParsersMustCompile("~*req.Destination2", utils.InfieldSep),
CustomerNumber: NewRSRParsersMustCompile("~*req.Destination2", utils.InfieldSep),
OrigNumber: NewRSRParsersMustCompile("~*req.Destination2", utils.InfieldSep),
TermNumber: NewRSRParsersMustCompile("~*req.CGRID2", utils.InfieldSep),
BillToNumber: NewRSRParsersMustCompile(utils.MetaNone, utils.InfieldSep),
Zipcode: NewRSRParsersMustCompile(utils.MetaNone, utils.InfieldSep),
Plus4: NewRSRParsersMustCompile(utils.MetaNone, utils.InfieldSep),
P2PZipcode: NewRSRParsersMustCompile(utils.MetaNone, utils.InfieldSep),
P2PPlus4: NewRSRParsersMustCompile(utils.MetaNone, utils.InfieldSep),
Units: NewRSRParsersMustCompile("2", utils.InfieldSep),
UnitType: NewRSRParsersMustCompile("000", utils.InfieldSep),
TaxIncluded: NewRSRParsersMustCompile("00", utils.InfieldSep),
TaxSitusRule: NewRSRParsersMustCompile("05", utils.InfieldSep),
TransTypeCode: NewRSRParsersMustCompile("01010101", utils.InfieldSep),
SalesTypeCode: NewRSRParsersMustCompile("S", utils.InfieldSep),
TaxExemptionCodeList: NewRSRParsersMustCompile(utils.MetaNone, utils.InfieldSep),
}
tLocal2, err := time.LoadLocation("UTC")
if err != nil {
t.Error(err)
}
v2 := &SureTaxCfg{
URL: "randomURL",
ClientNumber: "randomClient",
ValidationKey: "randomKey",
BusinessUnit: "randomUnit",
Timezone: tLocal2,
IncludeLocalCost: true,
ReturnFileCode: "1",
ResponseGroup: "06",
ResponseType: "A3",
RegulatoryCode: "06",
ClientTracking: NewRSRParsersMustCompile("~*req.Destination1", utils.InfieldSep),
CustomerNumber: NewRSRParsersMustCompile("~*req.Destination1", utils.InfieldSep),
OrigNumber: NewRSRParsersMustCompile("~*req.Destination1", utils.InfieldSep),
TermNumber: NewRSRParsersMustCompile("~*req.CGRID", utils.InfieldSep),
BillToNumber: NewRSRParsersMustCompile(utils.EmptyString, utils.InfieldSep),
Zipcode: NewRSRParsersMustCompile(utils.EmptyString, utils.InfieldSep),
Plus4: NewRSRParsersMustCompile(utils.EmptyString, utils.InfieldSep),
P2PZipcode: NewRSRParsersMustCompile(utils.EmptyString, utils.InfieldSep),
P2PPlus4: NewRSRParsersMustCompile(utils.EmptyString, utils.InfieldSep),
Units: NewRSRParsersMustCompile("1", utils.InfieldSep),
UnitType: NewRSRParsersMustCompile("00", utils.InfieldSep),
TaxIncluded: NewRSRParsersMustCompile("0", utils.InfieldSep),
TaxSitusRule: NewRSRParsersMustCompile("04", utils.InfieldSep),
TransTypeCode: NewRSRParsersMustCompile("010101", utils.InfieldSep),
SalesTypeCode: NewRSRParsersMustCompile("R", utils.InfieldSep),
TaxExemptionCodeList: NewRSRParsersMustCompile(utils.EmptyString, utils.InfieldSep),
}
expected := &SureTaxJsonCfg{
Url: utils.StringPointer("randomURL"),
Client_number: utils.StringPointer("randomClient"),
Validation_key: utils.StringPointer("randomKey"),
Business_unit: utils.StringPointer("randomUnit"),
Timezone: utils.StringPointer("UTC"),
Include_local_cost: utils.BoolPointer(true),
Return_file_code: utils.StringPointer("1"),
Response_group: utils.StringPointer("06"),
Response_type: utils.StringPointer("A3"),
Regulatory_code: utils.StringPointer("06"),
Client_tracking: utils.StringPointer("~*req.Destination1"),
Customer_number: utils.StringPointer("~*req.Destination1"),
Orig_number: utils.StringPointer("~*req.Destination1"),
Term_number: utils.StringPointer("~*req.CGRID"),
Bill_to_number: utils.StringPointer(utils.EmptyString),
Zipcode: utils.StringPointer(utils.EmptyString),
Plus4: utils.StringPointer(utils.EmptyString),
P2PZipcode: utils.StringPointer(utils.EmptyString),
P2PPlus4: utils.StringPointer(utils.EmptyString),
Units: utils.StringPointer("1"),
Unit_type: utils.StringPointer("00"),
Tax_included: utils.StringPointer("0"),
Tax_situs_rule: utils.StringPointer("04"),
Trans_type_code: utils.StringPointer("010101"),
Sales_type_code: utils.StringPointer("R"),
Tax_exemption_code_list: utils.StringPointer(utils.EmptyString),
}
rcv := diffSureTaxJsonCfg(d, v1, v2, ";")
if !reflect.DeepEqual(rcv, expected) {
t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(expected), utils.ToJSON(rcv))
}
v1 = v2
expected = &SureTaxJsonCfg{}
rcv = diffSureTaxJsonCfg(d, v1, v2, ";")
if !reflect.DeepEqual(rcv, expected) {
t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(expected), utils.ToJSON(rcv))
}
}

View File

@@ -20,6 +20,7 @@ package config
import (
"reflect"
"testing"
"time"
"github.com/cgrates/cgrates/utils"
)
@@ -132,3 +133,49 @@ func TestThresholdSCfgClone(t *testing.T) {
t.Errorf("Expected clone to not modify the cloned")
}
}
func TestDiffThresholdSJsonCfg(t *testing.T) {
var d *ThresholdSJsonCfg
v1 := &ThresholdSCfg{
Enabled: false,
IndexedSelects: false,
StoreInterval: 1 * time.Second,
StringIndexedFields: &[]string{"req.index1"},
PrefixIndexedFields: &[]string{"req.index2"},
SuffixIndexedFields: &[]string{"req.index3"},
NestedFields: false,
}
v2 := &ThresholdSCfg{
Enabled: true,
IndexedSelects: true,
StoreInterval: 2 * time.Second,
StringIndexedFields: &[]string{"req.index11"},
PrefixIndexedFields: &[]string{"req.index22"},
SuffixIndexedFields: &[]string{"req.index33"},
NestedFields: true,
}
expected := &ThresholdSJsonCfg{
Enabled: utils.BoolPointer(true),
Indexed_selects: utils.BoolPointer(true),
Store_interval: utils.StringPointer("2s"),
String_indexed_fields: &[]string{"req.index11"},
Prefix_indexed_fields: &[]string{"req.index22"},
Suffix_indexed_fields: &[]string{"req.index33"},
Nested_fields: utils.BoolPointer(true),
}
rcv := diffThresholdSJsonCfg(d, v1, v2)
if !reflect.DeepEqual(rcv, expected) {
t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(expected), utils.ToJSON(rcv))
}
v1 = v2
expected = &ThresholdSJsonCfg{}
rcv = diffThresholdSJsonCfg(d, v1, v2)
if !reflect.DeepEqual(rcv, expected) {
t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(expected), utils.ToJSON(rcv))
}
}

View File

@@ -117,3 +117,49 @@ func TestTLSCfgClone(t *testing.T) {
t.Errorf("Expected clone to not modify the cloned")
}
}
func TestDiffTlsJsonCfg(t *testing.T) {
var d *TlsJsonCfg
v1 := &TLSCfg{
ServerCerificate: "server_certificate",
ServerKey: "server_key",
ServerPolicy: 1,
ServerName: "server_name",
ClientCerificate: "client_certificate",
ClientKey: "client_key",
CaCertificate: "ca_certificate",
}
v2 := &TLSCfg{
ServerCerificate: "server_certificate2",
ServerKey: "server_key2",
ServerPolicy: 2,
ServerName: "server_name2",
ClientCerificate: "client_certificate2",
ClientKey: "client_key2",
CaCertificate: "ca_certificate2",
}
expected := &TlsJsonCfg{
Server_certificate: utils.StringPointer("server_certificate2"),
Server_key: utils.StringPointer("server_key2"),
Server_policy: utils.IntPointer(2),
Server_name: utils.StringPointer("server_name2"),
Client_certificate: utils.StringPointer("client_certificate2"),
Client_key: utils.StringPointer("client_key2"),
Ca_certificate: utils.StringPointer("ca_certificate2"),
}
rcv := diffTlsJsonCfg(d, v1, v2)
if !reflect.DeepEqual(rcv, expected) {
t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(expected), utils.ToJSON(rcv))
}
v1 = v2
expected = &TlsJsonCfg{}
rcv = diffTlsJsonCfg(d, v1, v2)
if !reflect.DeepEqual(rcv, expected) {
t.Errorf("Expected %v \n but received \n %v", utils.ToJSON(expected), utils.ToJSON(rcv))
}
}