@@ -178,11 +178,11 @@ func TestCoreSearchNoArgs(t *testing.T) {
178
178
require .Contains (t , lines , []string {"test:x86" , "2.0.0" , "test_core" })
179
179
numPlatforms := len (lines ) - 1
180
180
181
- // same thing in JSON format, also check the number of platforms found is the same
181
+ // Same thing in JSON format, also check the number of platforms found is the same
182
182
stdout , _ , err = cli .Run ("core" , "search" , "--format" , "json" )
183
183
require .NoError (t , err )
184
184
requirejson .Contains (t , stdout , `[{"id": "test:x86", "releases": { "2.0.0": {"name":"test_core"}}}]` )
185
- requirejson .Query (t , stdout , "length" , fmt .Sprint (numPlatforms ))
185
+ requirejson .Query (t , stdout , `[.[] | select(.latest_compatible_version != "")] | length` , fmt .Sprint (numPlatforms ))
186
186
187
187
// list all with additional urls, check the test core is there
188
188
stdout , _ , err = cli .Run ("core" , "search" , "--additional-urls=" + url .String ())
@@ -199,9 +199,7 @@ func TestCoreSearchNoArgs(t *testing.T) {
199
199
stdout , _ , err = cli .Run ("core" , "search" , "--format" , "json" , "--additional-urls=" + url .String ())
200
200
require .NoError (t , err )
201
201
requirejson .Contains (t , stdout , `[{"id": "test:x86", "releases": { "3.0.0": {"name":"test_core"}}}]` )
202
- // A platform could contain multiple releases, we get the length of how many releases are present for each platform
203
- // and we sum them to see if the expected numers matches.
204
- requirejson .Query (t , stdout , `[.[].releases | length] | add` , fmt .Sprint (numPlatforms ))
202
+ requirejson .Query (t , stdout , `[.[] | select(.latest_compatible_version != "")] | length` , fmt .Sprint (numPlatforms ))
205
203
}
206
204
207
205
func TestCoreUpdateIndexUrlNotFound (t * testing.T ) {
@@ -695,7 +693,7 @@ func TestCoreSearchSortedResults(t *testing.T) {
695
693
require .NoError (t , err )
696
694
697
695
out := strings .Split (strings .TrimSpace (string (stdout )), "\n " )
698
- var lines , deprecated , notDeprecated , incompatibles [][]string
696
+ var lines , deprecated , notDeprecated [][]string
699
697
for i , v := range out {
700
698
if i > 0 {
701
699
v = strings .Join (strings .Fields (v ), " " )
@@ -707,11 +705,7 @@ func TestCoreSearchSortedResults(t *testing.T) {
707
705
deprecated = append (deprecated , v )
708
706
continue
709
707
}
710
- if _ , err := semver .Parse (v [1 ]); err != nil {
711
- incompatibles = append (incompatibles , v )
712
- } else {
713
- notDeprecated = append (notDeprecated , v )
714
- }
708
+ notDeprecated = append (notDeprecated , v )
715
709
}
716
710
717
711
// verify that results are already sorted correctly
@@ -721,13 +715,9 @@ func TestCoreSearchSortedResults(t *testing.T) {
721
715
require .True (t , sort .SliceIsSorted (notDeprecated , func (i , j int ) bool {
722
716
return strings .ToLower (notDeprecated [i ][2 ]) < strings .ToLower (notDeprecated [j ][2 ])
723
717
}))
724
- require .True (t , sort .SliceIsSorted (incompatibles , func (i , j int ) bool {
725
- return strings .ToLower (incompatibles [i ][2 ]) < strings .ToLower (incompatibles [j ][2 ])
726
- }))
727
718
728
- result := append (notDeprecated , incompatibles ... )
729
719
// verify that deprecated platforms are the last ones
730
- require .Equal (t , lines , append (result , deprecated ... ))
720
+ require .Equal (t , lines , append (notDeprecated , deprecated ... ))
731
721
732
722
// test same behaviour with json output
733
723
stdout , _ , err = cli .Run ("core" , "search" , "--additional-urls=" + url .String (), "--format=json" )
@@ -1134,15 +1124,15 @@ func TestCoreHavingIncompatibleDepTools(t *testing.T) {
1134
1124
stdout , _ , err := cli .Run ("core" , "list" , "--all" , "--format" , "json" , additionalURLs )
1135
1125
require .NoError (t , err )
1136
1126
t .Log (string (stdout ))
1137
- requirejson .Query (t , stdout , `.[] | select(.id == "foo_vendor:avr") | .latest ` , `"1.0.2"` )
1138
- requirejson .Query (t , stdout , `.[] | select(.id == "foo_vendor:avr") | .latest_compatible ` , `"1.0.1"` )
1127
+ requirejson .Query (t , stdout , `.[] | select(.id == "foo_vendor:avr") | .latest_version ` , `"1.0.2"` )
1128
+ requirejson .Query (t , stdout , `.[] | select(.id == "foo_vendor:avr") | .latest_compatible_version ` , `"1.0.1"` )
1139
1129
1140
1130
// install latest compatible version
1141
1131
_ , _ , err = cli .Run ("core" , "install" , "foo_vendor:avr" , additionalURLs )
1142
1132
require .NoError (t , err )
1143
1133
stdout , _ , err = cli .Run ("core" , "list" , "--all" , "--format" , "json" , additionalURLs )
1144
1134
require .NoError (t , err )
1145
- requirejson .Query (t , stdout , `.[] | select(.id == "foo_vendor:avr") | .latest_compatible ` , `"1.0.1"` )
1135
+ requirejson .Query (t , stdout , `.[] | select(.id == "foo_vendor:avr") | .latest_compatible_version ` , `"1.0.1"` )
1146
1136
1147
1137
// install incompatible version
1148
1138
_ ,
stderr ,
err := cli .
Run (
"core" ,
"install" ,
"foo_vendor:[email protected] " ,
additionalURLs )
@@ -1154,26 +1144,34 @@ func TestCoreHavingIncompatibleDepTools(t *testing.T) {
1154
1144
require .NoError (t , err )
1155
1145
stdout , _ , err = cli .Run ("core" , "list" , "--format" , "json" , additionalURLs )
1156
1146
require .NoError (t , err )
1157
- requirejson .Query (t , stdout , `.[] | select(.id == "foo_vendor:avr") | .installed ` , `"1.0.0"` )
1147
+ requirejson .Query (t , stdout , `.[] | select(.id == "foo_vendor:avr") | .installed_version ` , `"1.0.0"` )
1158
1148
1159
1149
// Lists all updatable cores
1160
1150
stdout , _ , err = cli .Run ("core" , "list" , "--updatable" , "--format" , "json" , additionalURLs )
1161
1151
require .NoError (t , err )
1162
- requirejson .Query (t , stdout , `.[] | select(.id == "foo_vendor:avr") | .latest_compatible` , `"1.0.1"` )
1152
+ requirejson .Query (t , stdout , `.[] | select(.id == "foo_vendor:avr") | .latest_compatible_version` , `"1.0.1"` )
1153
+
1154
+ // Show outdated cores, must show latest compatible
1155
+ stdout , _ , err = cli .Run ("outdated" , "--format" , "json" , additionalURLs )
1156
+ require .NoError (t , err )
1157
+ requirejson .Query (t , stdout ,
1158
+ `.platforms | .[] | select(.id == "foo_vendor:avr") | {latest_compatible: .latest_compatible_version, latest: .latest_version}` ,
1159
+ `{"latest_compatible": "1.0.1", "latest": "1.0.2"}` ,
1160
+ )
1163
1161
1164
1162
// upgrade to latest compatible (1.0.0 -> 1.0.1)
1165
1163
_ , _ , err = cli .Run ("core" , "upgrade" , "foo_vendor:avr" , "--format" , "json" , additionalURLs )
1166
1164
require .NoError (t , err )
1167
1165
stdout , _ , err = cli .Run ("core" , "list" , "--format" , "json" , additionalURLs )
1168
1166
require .NoError (t , err )
1169
- requirejson .Query (t , stdout , `.[] | select(.id == "foo_vendor:avr") | .installed ` , `"1.0.1"` )
1167
+ requirejson .Query (t , stdout , `.[] | select(.id == "foo_vendor:avr") | .installed_version ` , `"1.0.1"` )
1170
1168
1171
1169
// upgrade to latest incompatible not possible (1.0.1 -> 1.0.2)
1172
1170
_ , _ , err = cli .Run ("core" , "upgrade" , "foo_vendor:avr" , "--format" , "json" , additionalURLs )
1173
1171
require .NoError (t , err )
1174
1172
stdout , _ , err = cli .Run ("core" , "list" , "--format" , "json" , additionalURLs )
1175
1173
require .NoError (t , err )
1176
- requirejson .Query (t , stdout , `.[] | select(.id == "foo_vendor:avr") | .installed ` , `"1.0.1"` )
1174
+ requirejson .Query (t , stdout , `.[] | select(.id == "foo_vendor:avr") | .installed_version ` , `"1.0.1"` )
1177
1175
1178
1176
// When no compatible version are found return error
1179
1177
_ , stderr , err = cli .Run ("core" , "install" , "incompatible_vendor:avr" , additionalURLs )
@@ -1184,19 +1182,19 @@ func TestCoreHavingIncompatibleDepTools(t *testing.T) {
1184
1182
stdout , _ , err = cli .Run ("core" , "search" , "--all" , "--format" , "json" , additionalURLs )
1185
1183
require .NoError (t , err )
1186
1184
requirejson .Query (t , stdout ,
1187
- `[.[] | select(.id == "foo_vendor:avr") | {latest : .latest , incompatible: .incompatible}] | sort_by(.latest )` ,
1185
+ `[.[] | select(.id == "foo_vendor:avr") | .releases | map(.) | .[] | {version : .version , incompatible: .incompatible}] | sort_by(.version )` ,
1188
1186
`[
1189
- {"incompatible":null,"latest ":"1.0.0"},
1190
- {"incompatible":null,"latest ":"1.0.1"},
1191
- {"incompatible":true,"latest ":"1.0.2"}
1187
+ {"incompatible":null,"version ":"1.0.0"},
1188
+ {"incompatible":null,"version ":"1.0.1"},
1189
+ {"incompatible":true,"version ":"1.0.2"}
1192
1190
]` ,
1193
1191
)
1194
1192
1195
- // Core search shows latest compatible version
1193
+ // Core search shows latest compatible version even if incompatible
1196
1194
stdout , _ , err = cli .Run ("core" , "search" , "--format" , "json" , additionalURLs )
1197
1195
require .NoError (t , err )
1198
- requirejson .Query (t , stdout , `.[] | select(.id == "foo_vendor:avr") | .latest ` , `"1.0.1 "` )
1199
- requirejson .Query (t , stdout , `.[] | select(.id == "incompatible_vendor:avr") | .incompatible` , `true` )
1196
+ requirejson .Query (t , stdout , `.[] | select(.id == "foo_vendor:avr") | .latest_version ` , `"1.0.2 "` )
1197
+ requirejson .Query (t , stdout , `.[] | select(.id == "incompatible_vendor:avr") | .releases[.latest_version]. incompatible` , `true` )
1200
1198
1201
1199
// In text mode, core search doesn't show any version if no compatible one are present
1202
1200
stdout , _ , err = cli .Run ("core" , "search" , additionalURLs )
@@ -1205,5 +1203,5 @@ func TestCoreHavingIncompatibleDepTools(t *testing.T) {
1205
1203
for _ , v := range strings .Split (strings .TrimSpace (string (stdout )), "\n " ) {
1206
1204
lines = append (lines , strings .Fields (strings .TrimSpace (v )))
1207
1205
}
1208
- require .Contains (t , lines , []string {"incompatible_vendor:avr" , "Incompatible" , "Boards " })
1206
+ require .NotContains (t , lines , []string {"incompatible_vendor:avr" })
1209
1207
}
0 commit comments