mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Tested FlagsWithParams.GetBool
This commit is contained in:
@@ -35,6 +35,9 @@
|
||||
|
||||
"cdrs": {
|
||||
"enabled": true, // start the CDR Server service: <true|false>
|
||||
"chargers_conns":[
|
||||
{"address": "*internal"}
|
||||
],
|
||||
"rals_conns": [
|
||||
{"address": "*internal"} // address where to reach the Rater <""|*internal|127.0.0.1:2013>
|
||||
],
|
||||
|
||||
@@ -22,6 +22,12 @@
|
||||
"cdrs": {
|
||||
"enabled": true, // start the CDR Server service: <true|false>
|
||||
"store_cdrs": false, // store cdrs in storDb
|
||||
"chargers_conns":[
|
||||
{"address": "*internal"}
|
||||
],
|
||||
"rals_conns": [
|
||||
{"address": "*internal"}
|
||||
],
|
||||
"online_cdr_exports": ["http_localhost", "amqp_localhost", "http_test_file", "amqp_test_file","aws_test_file","sqs_test_file","kafka_localhost","s3_test_file"],
|
||||
},
|
||||
|
||||
|
||||
@@ -20,6 +20,12 @@
|
||||
|
||||
"cdrs": {
|
||||
"enabled": true, // start the CDR Server service: <true|false>
|
||||
"chargers_conns":[
|
||||
{"address": "*internal"}
|
||||
],
|
||||
"rals_conns": [
|
||||
{"address": "*internal"}
|
||||
],
|
||||
},
|
||||
|
||||
"chargers": {
|
||||
|
||||
@@ -36,6 +36,9 @@
|
||||
"chargers_conns":[
|
||||
{"address": "*internal"}
|
||||
],
|
||||
"rals_conns": [
|
||||
{"address": "*internal"}
|
||||
],
|
||||
},
|
||||
|
||||
|
||||
|
||||
@@ -299,7 +299,7 @@ func (fWp FlagsWithParams) GetBool(key string) (b bool) {
|
||||
if v, b = fWp[key]; !b {
|
||||
return // not present means false
|
||||
}
|
||||
if v != nil && len(v) != 0 {
|
||||
if v == nil || len(v) == 0 {
|
||||
return false // empty slice
|
||||
}
|
||||
return v[0] == "true" // check only the first element
|
||||
|
||||
@@ -213,3 +213,27 @@ func TestFlagsToSlice(t *testing.T) {
|
||||
t.Errorf("Expecting: %+v, received: %+v", sls, flgSls)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFlagsWithParamsGetBool(t *testing.T) {
|
||||
flagsWithParams := &FlagsWithParams{
|
||||
"test": []string{"string1", "string2"},
|
||||
"test2": []string{"true", "string2"},
|
||||
"empty": []string{},
|
||||
}
|
||||
key := "notpresent"
|
||||
if rcv := flagsWithParams.GetBool(key); rcv != false {
|
||||
t.Errorf("Expecting: false, received: %+v", ToJSON(rcv))
|
||||
}
|
||||
key = "empty"
|
||||
if rcv := flagsWithParams.GetBool(key); rcv != false {
|
||||
t.Errorf("Expecting: false, received: %+v", ToJSON(rcv))
|
||||
}
|
||||
key = "test"
|
||||
if rcv := flagsWithParams.GetBool(key); rcv != false {
|
||||
t.Errorf("Expecting: false, received: %+v", ToJSON(rcv))
|
||||
}
|
||||
key = "test2"
|
||||
if rcv := flagsWithParams.GetBool(key); rcv != true {
|
||||
t.Errorf("Expecting: true, received: %+v", ToJSON(rcv))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user