@@ -946,7 +946,6 @@ func TestBoolNamedArguments(t *testing.T) {
946
946
// TestArrayIntNamedArguments tests successful function execution
947
947
// with array arguments and integer return value
948
948
func TestArrayIntNamedArguments (t * testing.T ) {
949
- t .Skip ("Bug(sickyoon): array as an argument returns nil: https://github.com/gocelery/gocelery/issues/74" )
950
949
testCases := []struct {
951
950
name string
952
951
broker CeleryBroker
@@ -1020,7 +1019,6 @@ func TestArrayIntNamedArguments(t *testing.T) {
1020
1019
// TestArray tests successful function execution
1021
1020
// with array arguments and return value
1022
1021
func TestArray (t * testing.T ) {
1023
- t .Skip ("Bug(sickyoon): array as an argument returns nil: https://github.com/gocelery/gocelery/issues/74" )
1024
1022
testCases := []struct {
1025
1023
name string
1026
1024
broker CeleryBroker
@@ -1078,7 +1076,7 @@ func TestArray(t *testing.T) {
1078
1076
cli .StopWorker ()
1079
1077
continue
1080
1078
}
1081
- if ! reflect .DeepEqual (tc .expected , res .([] string )) {
1079
+ if ! reflect .DeepEqual (tc .expected , convertInterfaceToStringSlice ( res )) {
1082
1080
t .Errorf ("test '%s': returned result %+v is different from expected result %+v" , tc .name , res , tc .expected )
1083
1081
}
1084
1082
cli .StopWorker ()
@@ -1088,7 +1086,6 @@ func TestArray(t *testing.T) {
1088
1086
// TestMap tests successful function execution
1089
1087
// with map arguments and return value
1090
1088
func TestMap (t * testing.T ) {
1091
- t .Skip ("Bug(sickyoon): map as an argument returns nil: https://github.com/gocelery/gocelery/issues/74" )
1092
1089
testCases := []struct {
1093
1090
name string
1094
1091
broker CeleryBroker
@@ -1146,7 +1143,7 @@ func TestMap(t *testing.T) {
1146
1143
cli .StopWorker ()
1147
1144
continue
1148
1145
}
1149
- if ! reflect .DeepEqual (tc .expected , res .( map [ string ] string )) {
1146
+ if ! reflect .DeepEqual (tc .expected , convertInterfaceToStringMap ( res )) {
1150
1147
t .Errorf ("test '%s': returned result %+v is different from expected result %+v" , tc .name , res , tc .expected )
1151
1148
}
1152
1149
cli .StopWorker ()
@@ -1398,18 +1395,12 @@ func (m *maxArrLenTask) ParseKwargs(kwargs map[string]interface{}) error {
1398
1395
if ! ok {
1399
1396
return fmt .Errorf ("undefined kwarg a" )
1400
1397
}
1401
- m .a , ok = kwargA .([]string )
1402
- if ! ok {
1403
- return fmt .Errorf ("malformed kwarg a" )
1404
- }
1398
+ m .a = convertInterfaceToStringSlice (kwargA )
1405
1399
kwargB , ok := kwargs ["b" ]
1406
1400
if ! ok {
1407
1401
return fmt .Errorf ("undefined kwarg b" )
1408
1402
}
1409
- m .b , ok = kwargB .([]string )
1410
- if ! ok {
1411
- return fmt .Errorf ("malformed kwarg b" )
1412
- }
1403
+ m .b = convertInterfaceToStringSlice (kwargB )
1413
1404
return nil
1414
1405
}
1415
1406
@@ -1437,3 +1428,21 @@ func addMap(a, b map[string]interface{}) map[string]interface{} {
1437
1428
}
1438
1429
return c
1439
1430
}
1431
+
1432
+ func convertInterfaceToStringSlice (i interface {}) []string {
1433
+ is := i .([]interface {})
1434
+ stringSlice := make ([]string , len (is ))
1435
+ for i , v := range is {
1436
+ stringSlice [i ] = fmt .Sprint (v )
1437
+ }
1438
+ return stringSlice
1439
+ }
1440
+
1441
+ func convertInterfaceToStringMap (i interface {}) map [string ]string {
1442
+ im := i .(map [string ]interface {})
1443
+ stringMap := make (map [string ]string , len (im ))
1444
+ for i , v := range im {
1445
+ stringMap [i ] = fmt .Sprint (v )
1446
+ }
1447
+ return stringMap
1448
+ }
0 commit comments