mirror of
https://github.com/rumanzo/bt2qbt.git
synced 2024-11-22 10:22:38 +01:00
Fix handling trackers. Test cover
This commit is contained in:
parent
f2decc007c
commit
2d91e47377
@ -144,15 +144,20 @@ func (transfer *TransferStructure) HandleLabels() {
|
||||
// GetTrackers recurstive function for searching trackers in resume item trackers
|
||||
func (transfer *TransferStructure) GetTrackers(trackers interface{}) {
|
||||
switch strct := trackers.(type) {
|
||||
case []interface{}:
|
||||
for _, st := range strct {
|
||||
transfer.GetTrackers(st)
|
||||
case []string:
|
||||
for _, str := range strct {
|
||||
for _, str := range strings.Fields(str) {
|
||||
transfer.Fastresume.Trackers = append(transfer.Fastresume.Trackers, []string{str})
|
||||
}
|
||||
}
|
||||
case string:
|
||||
for _, str := range strings.Fields(strct) {
|
||||
transfer.Fastresume.Trackers = append(transfer.Fastresume.Trackers, []string{str})
|
||||
}
|
||||
|
||||
case []interface{}:
|
||||
for _, st := range strct {
|
||||
transfer.GetTrackers(st)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1139,6 +1139,9 @@ func TestTransferStructure_GetTrackers(t *testing.T) {
|
||||
"test6",
|
||||
},
|
||||
},
|
||||
[]interface{}{
|
||||
[]interface{}{"test7", "test8"},
|
||||
},
|
||||
}
|
||||
expect := [][]string{
|
||||
[]string{"test1"},
|
||||
@ -1147,6 +1150,8 @@ func TestTransferStructure_GetTrackers(t *testing.T) {
|
||||
[]string{"test4"},
|
||||
[]string{"test5"},
|
||||
[]string{"test6"},
|
||||
[]string{"test7"},
|
||||
[]string{"test8"},
|
||||
}
|
||||
transferStructure.GetTrackers(testTrackers)
|
||||
if !reflect.DeepEqual(transferStructure.Fastresume.Trackers, expect) {
|
||||
|
Loading…
Reference in New Issue
Block a user