@@ -11,33 +11,66 @@ import (
11
11
"golift.io/starr/sonarr"
12
12
)
13
13
14
- func TestCopyIndexer (t * testing.T ) {
14
+ func TestCopyIndexers (t * testing.T ) {
15
15
t .Parallel ()
16
+ src1 , dst1 := copyData (t )
17
+ src2 , dst2 := copyData (t )
18
+ src3 , dst3 := copyData (t )
19
+ src4 , _ := copyData (t )
20
+ src5 , _ := copyData (t )
21
+ // We test for these.
22
+ src1 .Priority = 1
23
+ src2 .Priority = 2
24
+ src3 .Priority = 3
25
+ src4 .Priority = 4
26
+ src5 .Priority = 5
27
+ // Make two lists.
28
+ srcs := append ([]* prowlarr.IndexerOutput {}, src1 , src2 , src3 , src4 , src5 )
29
+ dsts := append ([]* sonarr.IndexerInput {}, dst1 , dst2 , dst3 ) // short by 2.
30
+ // Copy the lists.
31
+ dsts2 , err := orbit .CopyIndexers (srcs , & dsts , false )
32
+ require .NoError (t , err )
33
+ // Make sure both outputs have a length matching the input.
34
+ assert .Len (t , dsts , len (srcs ))
35
+ assert .Len (t , dsts2 , len (srcs ))
36
+ // Test that values got copied.
37
+ for idx , src := range srcs {
38
+ assert .Equal (t , src .Priority , dsts [idx ].Priority )
39
+ }
40
+ }
41
+
42
+ func copyData (t * testing.T ) (* prowlarr.IndexerOutput , * sonarr.IndexerInput ) {
43
+ t .Helper ()
16
44
17
- src := & prowlarr.IndexerOutput {
18
- ID : 2 ,
19
- Priority : 3 ,
20
- Name : "yes" ,
21
- Protocol : "usenet" ,
22
- Implementation : "core" ,
23
- ConfigContract : "hancock" ,
24
- Tags : []int {1 , 2 , 5 },
25
- Fields : []* starr.FieldOutput {
26
- {Name : "One" , Value : "one" },
27
- {Name : "Two" , Value : 2.0 },
28
- {Name : "Three" , Value : uint (3 )},
29
- {Name : "Five" , Value : 5 },
45
+ return & prowlarr.IndexerOutput {
46
+ ID : 2 ,
47
+ Priority : 3 ,
48
+ Name : "yes" ,
49
+ Protocol : "usenet" ,
50
+ Implementation : "core" ,
51
+ ConfigContract : "hancock" ,
52
+ Tags : []int {1 , 2 , 5 },
53
+ Fields : []* starr.FieldOutput {
54
+ {Name : "One" , Value : "one" },
55
+ {Name : "Two" , Value : 2.0 },
56
+ {Name : "Three" , Value : uint (3 )},
57
+ {Name : "Five" , Value : 5 },
58
+ },
30
59
},
31
- }
32
- // This is a real example of how you'd copy an indexer from Prowlarr to Sonarr.
33
- dst := & sonarr.IndexerInput {
34
- // These are not part of the used input, so set them before copying.
35
- EnableAutomaticSearch : true ,
36
- EnableInteractiveSearch : true ,
37
- EnableRss : true ,
38
- DownloadClientID : 15 ,
39
- }
60
+ // This is a real example of how you'd copy an indexer from Prowlarr to Sonarr.
61
+ & sonarr.IndexerInput {
62
+ // These are not part of the used input, so set them before copying.
63
+ EnableAutomaticSearch : true ,
64
+ EnableInteractiveSearch : true ,
65
+ EnableRss : true ,
66
+ DownloadClientID : 15 ,
67
+ }
68
+ }
69
+
70
+ func TestCopyIndexer (t * testing.T ) {
71
+ t .Parallel ()
40
72
73
+ src , dst := copyData (t )
41
74
// Verify everything copies over.
42
75
_ , err := orbit .CopyIndexer (src , dst , true )
43
76
require .NoError (t , err )
0 commit comments