@@ -49,39 +49,41 @@ def test_core_search(run_command, httpserver):
49
49
result = run_command (f"core search retrokit --all --additional-urls={ url } " )
50
50
assert result .ok
51
51
lines = [l .strip ().split () for l in result .stdout .strip ().splitlines ()]
52
- assert 11 == len (lines )
53
52
assert ["Updating" , "index:" , "package_index.json" , "downloaded" ] in lines
54
53
assert ["Updating" , "index:" , "package_index.json.sig" , "downloaded" ] in lines
55
54
assert ["Retrokits-RK002:arm" , "1.0.5" , "RK002" ] in lines
56
55
assert ["Retrokits-RK002:arm" , "1.0.6" , "RK002" ] in lines
56
+ header_index = lines .index (["ID" , "Version" , "Name" ])
57
+ assert 2 == len (lines [header_index + 1 :])
57
58
58
59
# Search using Retrokit Package Maintainer
59
60
result = run_command (f"core search Retrokits-RK002 --all --additional-urls={ url } " )
60
61
assert result .ok
61
62
lines = [l .strip ().split () for l in result .stdout .strip ().splitlines ()]
62
- assert 11 == len (lines )
63
63
assert ["Updating" , "index:" , "package_index.json" , "downloaded" ] in lines
64
64
assert ["Updating" , "index:" , "package_index.json.sig" , "downloaded" ] in lines
65
65
assert ["Retrokits-RK002:arm" , "1.0.5" , "RK002" ] in lines
66
66
assert ["Retrokits-RK002:arm" , "1.0.6" , "RK002" ] in lines
67
+ assert 2 == len (lines [header_index + 1 :])
67
68
68
69
# Search using the Retrokit Platform name
69
70
result = run_command (f"core search rk002 --all --additional-urls={ url } " )
70
71
assert result .ok
71
- assert 11 == len ( lines )
72
+ lines = [ l . strip (). split () for l in result . stdout . strip (). splitlines ()]
72
73
assert ["Updating" , "index:" , "package_index.json" , "downloaded" ] in lines
73
74
assert ["Updating" , "index:" , "package_index.json.sig" , "downloaded" ] in lines
74
75
assert ["Retrokits-RK002:arm" , "1.0.5" , "RK002" ] in lines
75
76
assert ["Retrokits-RK002:arm" , "1.0.6" , "RK002" ] in lines
77
+ assert 2 == len (lines [header_index + 1 :])
76
78
77
79
# Search using a board name
78
80
result = run_command (f"core search myboard --all --additional-urls={ url } " )
79
81
assert result .ok
80
- assert 10 == len (result .stdout .strip ().splitlines ())
81
82
lines = [l .strip ().split () for l in result .stdout .strip ().splitlines ()]
82
83
assert ["Updating" , "index:" , "package_index.json" , "downloaded" ] in lines
83
84
assert ["Updating" , "index:" , "package_index.json.sig" , "downloaded" ] in lines
84
85
assert ["Package:x86" , "1.2.3" , "Platform" ] in lines
86
+ assert 1 == len (lines [header_index + 1 :])
85
87
86
88
87
89
def test_core_search_no_args (run_command , httpserver ):
@@ -104,11 +106,11 @@ def test_core_search_no_args(run_command, httpserver):
104
106
num_platforms = 0
105
107
lines = [l .strip ().split () for l in result .stdout .strip ().splitlines ()]
106
108
# Index update output and the header are printed on the first lines
107
- assert ["Updating" , "index:" , "package_index.json" , "downloaded" ] in lines [: 6 ]
108
- assert ["Updating" , "index:" , "package_index.json.sig" , "downloaded" ] in lines [: 6 ]
109
- assert ["ID " , "Version " , "Name " ] == lines [ 5 ]
110
- assert [ "test:x86 " , "2.0.0 " , "test_core" ] in lines [ 6 :]
111
- num_platforms = len (lines [6 :])
109
+ assert ["Updating" , "index:" , "package_index.json" , "downloaded" ] in lines
110
+ assert ["Updating" , "index:" , "package_index.json.sig" , "downloaded" ] in lines
111
+ assert ["test:x86 " , "2.0.0 " , "test_core " ] in lines
112
+ header_index = lines . index ([ "ID " , "Version " , "Name" ])
113
+ num_platforms = len (lines [header_index + 1 :])
112
114
113
115
# same thing in JSON format, also check the number of platforms found is the same
114
116
result = run_command ("core search --format json" )
@@ -123,11 +125,11 @@ def test_core_search_no_args(run_command, httpserver):
123
125
num_platforms = 0
124
126
lines = [l .strip ().split () for l in result .stdout .strip ().splitlines ()]
125
127
# Index update output and the header are printed on the first lines
126
- assert ["Updating" , "index:" , "package_index.json" , "downloaded" ] in lines [: 9 ]
127
- assert ["Updating" , "index:" , "package_index.json.sig" , "downloaded" ] in lines [: 9 ]
128
- assert ["ID " , "Version " , "Name " ] == lines [ 8 ]
129
- assert [ "test:x86 " , "2.0.0 " , "test_core" ] in lines [ 9 :]
130
- num_platforms = len (lines [9 :])
128
+ assert ["Updating" , "index:" , "package_index.json" , "downloaded" ] in lines
129
+ assert ["Updating" , "index:" , "package_index.json.sig" , "downloaded" ] in lines
130
+ assert ["test:x86 " , "2.0.0 " , "test_core " ] in lines
131
+ header_index = lines . index ([ "ID " , "Version " , "Name" ])
132
+ num_platforms = len (lines [header_index + 1 :])
131
133
132
134
# same thing in JSON format, also check the number of platforms found is the same
133
135
result = run_command (f"core search --format json --additional-urls={ url } " )
0 commit comments