Apply gofmt

This commit is contained in:
ionutboangiu
2023-07-14 17:25:13 -04:00
committed by Dan Christian Bogos
parent f3428e298d
commit 8174618f73
4 changed files with 140 additions and 140 deletions

View File

@@ -419,4 +419,4 @@ func TestBalanceFilterModifyBalance(t *testing.T) {
}
bf.ModifyBalance(nil)
}
}

View File

@@ -591,7 +591,7 @@ func TestBalanceHasBalance(t *testing.T) {
bc := Balances{}
b := Balance{}
rcv := bc.HasBalance(&b)
rcv := bc.HasBalance(&b)
if rcv != false {
t.Error(rcv)
@@ -599,7 +599,7 @@ func TestBalanceHasBalance(t *testing.T) {
bc2 := Balances{&b}
rcv = bc2.HasBalance(&b)
rcv = bc2.HasBalance(&b)
if rcv != true {
t.Error(rcv)

View File

@@ -2184,57 +2184,57 @@ func TestValidateCallData(t *testing.T) {
func TestCallDescNewCallDescriptorFromCGREvent(t *testing.T) {
c := utils.CGREvent{
Event: map[string]any{
Event: map[string]any{
"Account": "test",
},
}
c2 := utils.CGREvent{
Event: map[string]any{
"Account": "test",
"Subject": "test",
Event: map[string]any{
"Account": "test",
"Subject": "test",
"Destination": "test",
},
}
c3 := utils.CGREvent{
Event: map[string]any{
"Account": "test",
"Subject": "test",
Event: map[string]any{
"Account": "test",
"Subject": "test",
"Destination": "test",
"SetupTime": "*daily",
"SetupTime": "*daily",
},
}
type args struct {
cgrEv *utils.CGREvent
cgrEv *utils.CGREvent
timezone string
}
type exp struct {
cd *CallDescriptor
cd *CallDescriptor
err string
}
tests := []struct{
name string
args args
exp exp
tests := []struct {
name string
args args
exp exp
}{
{
name: "subject and destiantion field as string error check",
args: args{&c, ""},
exp: exp{nil, utils.ErrNotFound.Error()},
exp: exp{nil, utils.ErrNotFound.Error()},
},
{
name: "setup time field as time error check",
args: args{&c2, ""},
exp: exp{nil, utils.ErrNotFound.Error()},
exp: exp{nil, utils.ErrNotFound.Error()},
},
{
name: "answer time field as time error check",
args: args{&c3, "UTC"},
exp: exp{nil, utils.ErrNotFound.Error()},
exp: exp{nil, utils.ErrNotFound.Error()},
},
}
@@ -2257,7 +2257,7 @@ func TestCallDescNewCallDescriptorFromCGREvent(t *testing.T) {
func TestCallDescAsCGREvet(t *testing.T) {
cd := CallDescriptor{
ExtraFields: map[string]string{"test": "test"},
ExtraFields: map[string]string{"test": "test"},
}
rcv := cd.AsCGREvent()
@@ -2265,89 +2265,89 @@ func TestCallDescAsCGREvet(t *testing.T) {
if rcv.Event["test"] != "test" {
t.Error(rcv.Event["test"])
}
}
}
func TestCallDescUpdateFromCGREvent(t *testing.T) {
func TestCallDescUpdateFromCGREvent(t *testing.T) {
cd := CallDescriptor{
ExtraFields: map[string]string{},
ExtraFields: map[string]string{},
}
c := utils.CGREvent{
Event: map[string]any{
Event: map[string]any{
"Test2": "test",
},
}
c2 := utils.CGREvent{
Event: map[string]any{
Event: map[string]any{
"Usage": 1 * time.Millisecond,
},
}
type args struct {
cgrEv *utils.CGREvent
cgrEv *utils.CGREvent
fields []string
}
tests := []struct {
name string
args args
err string
name string
args args
err string
}{
{
name: "ToR field as string error check",
args: args{&c, []string{"ToR"}},
err: utils.ErrNotFound.Error(),
err: utils.ErrNotFound.Error(),
},
{
name: "Tenant field as string error check",
args: args{&c, []string{"Tenant"}},
err: utils.ErrNotFound.Error(),
err: utils.ErrNotFound.Error(),
},
{
name: "Category field as string error check",
args: args{&c, []string{"Category"}},
err: utils.ErrNotFound.Error(),
err: utils.ErrNotFound.Error(),
},
{
name: "Account field as string error check",
args: args{&c, []string{"Account"}},
err: utils.ErrNotFound.Error(),
err: utils.ErrNotFound.Error(),
},
{
name: "Subject field as string error check",
args: args{&c, []string{"Subject"}},
err: utils.ErrNotFound.Error(),
err: utils.ErrNotFound.Error(),
},
{
name: "Destination field as string error check",
args: args{&c, []string{"Destination"}},
err: utils.ErrNotFound.Error(),
err: utils.ErrNotFound.Error(),
},
{
name: "AnswerTime field as string error check",
args: args{&c, []string{"AnswerTime"}},
err: utils.ErrNotFound.Error(),
err: utils.ErrNotFound.Error(),
},
{
name: "Usage field as string error check",
args: args{&c, []string{"Usage"}},
err: utils.ErrNotFound.Error(),
err: utils.ErrNotFound.Error(),
},
{
name: "Usage field as string error check",
args: args{&c2, []string{"Usage"}},
err: "",
err: "",
},
{
name: "Default error check",
args: args{&c, []string{"Test"}},
err: utils.ErrNotFound.Error(),
err: utils.ErrNotFound.Error(),
},
{
name: "Default error check",
args: args{&c, []string{"Test2"}},
err: "",
err: "",
},
}
@@ -2362,9 +2362,9 @@ func TestCallDescAsCGREvet(t *testing.T) {
}
})
}
}
}
func TestCallDescgetAccount(t *testing.T) {
func TestCallDescgetAccount(t *testing.T) {
cd := CallDescriptor{
account: &Account{
Disabled: true,
@@ -2380,11 +2380,11 @@ func TestCallDescAsCGREvet(t *testing.T) {
if rcv != nil {
t.Error(rcv)
}
}
}
func TestCallDescDebit(t *testing.T) {
func TestCallDescDebit(t *testing.T) {
cd := CallDescriptor{
account: &Account{
account: &Account{
Disabled: true,
},
}
@@ -2400,11 +2400,11 @@ func TestCallDescAsCGREvet(t *testing.T) {
if rcv != nil {
t.Errorf("received %v, expected %v", rcv, nil)
}
}
}
func TestCallDescMaxDebit(t *testing.T) {
func TestCallDescMaxDebit(t *testing.T) {
cd := CallDescriptor{
account: &Account{
account: &Account{
Disabled: true,
},
}
@@ -2420,9 +2420,9 @@ func TestCallDescAsCGREvet(t *testing.T) {
if rcv != nil {
t.Errorf("received %v, expected %v", rcv, nil)
}
}
}
func TestCallDescAccountSummary(t *testing.T) {
func TestCallDescAccountSummary(t *testing.T) {
cd := CallDescriptor{
account: nil,
}
@@ -2434,9 +2434,9 @@ func TestCallDescAsCGREvet(t *testing.T) {
if rcv != nil {
t.Error(rcv)
}
}
}
func TestCallDescFieldAsInterface(t *testing.T) {
func TestCallDescFieldAsInterface(t *testing.T) {
cd := CallDescriptor{}
rcv, err := cd.FieldAsInterface([]string{})
@@ -2447,9 +2447,9 @@ func TestCallDescAsCGREvet(t *testing.T) {
if rcv != nil {
t.Error(rcv)
}
}
}
func TestCallDescFieldAsString(t *testing.T) {
func TestCallDescFieldAsString(t *testing.T) {
cd := CallDescriptor{}
rcv, err := cd.FieldAsString([]string{})
@@ -2460,9 +2460,9 @@ func TestCallDescAsCGREvet(t *testing.T) {
if rcv != "" {
t.Error(rcv)
}
}
}
func TestCallDescString(t *testing.T) {
func TestCallDescString(t *testing.T) {
cd := CallDescriptor{}
rcv := cd.String()
@@ -2470,9 +2470,9 @@ func TestCallDescAsCGREvet(t *testing.T) {
if rcv != `{"Category":"","Tenant":"","Subject":"","Account":"","Destination":"","TimeStart":"0001-01-01T00:00:00Z","TimeEnd":"0001-01-01T00:00:00Z","LoopIndex":0,"DurationIndex":0,"FallbackSubject":"","RatingInfos":null,"Increments":null,"ToR":"","ExtraFields":null,"MaxRate":0,"MaxRateUnit":0,"MaxCostSoFar":0,"CgrID":"","RunID":"","ForceDuration":false,"PerformRounding":false,"DryRun":false,"DenyNegativeAccount":false}` {
t.Error(rcv)
}
}
}
func TestCallDescRemoteHost(t *testing.T) {
func TestCallDescRemoteHost(t *testing.T) {
cd := CallDescriptor{}
rcv := cd.RemoteHost()
@@ -2480,4 +2480,4 @@ func TestCallDescAsCGREvet(t *testing.T) {
if rcv.String() != "local" {
t.Error(rcv)
}
}
}

View File

@@ -87,92 +87,92 @@ func TestStorageDecodeCodecMsgpackMarshaler(t *testing.T) {
var s stc
mp := make(map[string]any)
var slc []string
var slc []string
var slcB []byte
var arr [1]int
var nm int
var fl float64
var str string
var str string
var bl bool
var td time.Duration
tests := []struct{
name string
tests := []struct {
name string
expBytes []byte
val any
decode any
rng bool
val any
decode any
rng bool
}{
{
name: "map",
{
name: "map",
expBytes: []byte{129, 164, 107, 101, 121, 49, 166, 118, 97, 108, 117, 101, 49},
val: map[string]any{"key1": "value1",},
decode: mp,
rng: true,
},
{
name: "int",
val: map[string]any{"key1": "value1"},
decode: mp,
rng: true,
},
{
name: "int",
expBytes: []byte{1},
val: 1,
decode: nm,
rng: false,
},
{
name: "string",
val: 1,
decode: nm,
rng: false,
},
{
name: "string",
expBytes: []byte{164, 116, 101, 115, 116},
val: "test",
decode: str,
rng: false,
},
{
name: "float64",
val: "test",
decode: str,
rng: false,
},
{
name: "float64",
expBytes: []byte{203, 63, 248, 0, 0, 0, 0, 0, 0},
val: 1.5,
decode: fl,
rng: false,
},
{
name: "boolean",
val: 1.5,
decode: fl,
rng: false,
},
{
name: "boolean",
expBytes: []byte{195},
val: true,
decode: bl,
rng: false,
},
{
name: "slice",
val: true,
decode: bl,
rng: false,
},
{
name: "slice",
expBytes: []byte{145, 164, 118, 97, 108, 49},
val: []string{"val1"},
decode: slc,
rng: true,
},
{
name: "array",
val: []string{"val1"},
decode: slc,
rng: true,
},
{
name: "array",
expBytes: []byte{145, 1},
val: [1]int{1},
decode: arr,
rng: true,
},
{
name: "struct",
val: [1]int{1},
decode: arr,
rng: true,
},
{
name: "struct",
expBytes: []byte{129, 164, 78, 97, 109, 101, 164, 116, 101, 115, 116},
val: stc{"test"},
decode: s,
rng: true,
},
{
name: "time duration",
val: stc{"test"},
decode: s,
rng: true,
},
{
name: "time duration",
expBytes: []byte{210, 59, 154, 202, 0},
val: 1 * time.Second,
decode: td,
rng: false,
},
{
name: "slice of bytes",
val: 1 * time.Second,
decode: td,
rng: false,
},
{
name: "slice of bytes",
expBytes: []byte{162, 5, 8},
val: []byte{5, 8},
decode: slcB,
rng: true,
},
val: []byte{5, 8},
decode: slcB,
rng: true,
},
}
for _, tt := range tests {
@@ -186,19 +186,19 @@ func TestStorageDecodeCodecMsgpackMarshaler(t *testing.T) {
if !bytes.Equal(b, tt.expBytes) {
t.Fatalf("expected: %+v,\nreceived: %+v", tt.expBytes, b)
}
err = ms.Unmarshal(b, &tt.decode)
if err != nil {
t.Fatal(err)
}
if tt.rng {
if !reflect.DeepEqual(tt.decode, tt.val) {
t.Errorf("expected %v, received %v",tt.val, tt.decode)
t.Errorf("expected %v, received %v", tt.val, tt.decode)
}
} else {
if tt.decode != tt.val {
t.Errorf("expected %v, received %v",tt.val, tt.decode)
t.Errorf("expected %v, received %v", tt.val, tt.decode)
}
}
})
@@ -1706,24 +1706,24 @@ func TestStorageUtilsBuildURL(t *testing.T) {
func TestCSVNewGoogleCSVStorage(t *testing.T) {
type args struct {
sep rune
sep rune
spreadsheetId, cfgPath string
}
type exp struct {
c *CSVStorage
c *CSVStorage
err string
}
tests := []struct{
name string
args args
exp exp
tests := []struct {
name string
args args
exp exp
}{
{
name: "newSheet error check",
args: args{' ', "test", "test"},
exp: exp{nil, "Unable to read client secret file: open test/.gapi/credentials.json: no such file or directory"},
exp: exp{nil, "Unable to read client secret file: open test/.gapi/credentials.json: no such file or directory"},
},
}
@@ -1735,8 +1735,8 @@ func TestCSVNewGoogleCSVStorage(t *testing.T) {
}
if !reflect.DeepEqual(rcv, tt.exp.c) {
t.Errorf("received %v, expected %v", rcv, tt.exp.c)
t.Errorf("received %v, expected %v", rcv, tt.exp.c)
}
})
}
}
}