@@ -667,7 +667,7 @@ func TestCoreSearchSortedResults(t *testing.T) {
667
667
require .NoError (t , err )
668
668
669
669
out := strings .Split (strings .TrimSpace (string (stdout )), "\n " )
670
- var lines , deprecated , notDeprecated [][]string
670
+ var lines , deprecated , notDeprecated , incompatibles [][]string
671
671
for i , v := range out {
672
672
if i > 0 {
673
673
v = strings .Join (strings .Fields (v ), " " )
@@ -677,6 +677,10 @@ func TestCoreSearchSortedResults(t *testing.T) {
677
677
for _ , v := range lines {
678
678
if strings .HasPrefix (v [2 ], "[DEPRECATED]" ) {
679
679
deprecated = append (deprecated , v )
680
+ continue
681
+ }
682
+ if _ , err := semver .Parse (v [1 ]); err != nil {
683
+ incompatibles = append (incompatibles , v )
680
684
} else {
681
685
notDeprecated = append (notDeprecated , v )
682
686
}
@@ -689,9 +693,13 @@ func TestCoreSearchSortedResults(t *testing.T) {
689
693
require .True (t , sort .SliceIsSorted (notDeprecated , func (i , j int ) bool {
690
694
return strings .ToLower (notDeprecated [i ][2 ]) < strings .ToLower (notDeprecated [j ][2 ])
691
695
}))
696
+ require .True (t , sort .SliceIsSorted (incompatibles , func (i , j int ) bool {
697
+ return strings .ToLower (incompatibles [i ][2 ]) < strings .ToLower (incompatibles [j ][2 ])
698
+ }))
692
699
700
+ result := append (notDeprecated , incompatibles ... )
693
701
// verify that deprecated platforms are the last ones
694
- require .Equal (t , lines , append (notDeprecated , deprecated ... ))
702
+ require .Equal (t , lines , append (result , deprecated ... ))
695
703
696
704
// test same behaviour with json output
697
705
stdout , _ , err = cli .Run ("core" , "search" , "--additional-urls=" + url .String (), "--format=json" )
@@ -705,7 +713,7 @@ func TestCoreSearchSortedResults(t *testing.T) {
705
713
require .Equal (t , sortedDeprecated , notSortedDeprecated )
706
714
707
715
sortedNotDeprecated := requirejson .Parse (t , stdout ).Query (
708
- "[ .[] | select(.deprecated != true) | .name |=ascii_downcase | .name ] | sort " ).String ()
716
+ "[ .[] | select(.deprecated != true) | .name |=ascii_downcase | {name: .name, incompatible:.incompatible} ] | sort_by(.incompatible) | [.[] | .name] " ).String ()
709
717
notSortedNotDeprecated := requirejson .Parse (t , stdout ).Query (
710
718
"[.[] | select(.deprecated != true) | .name |=ascii_downcase | .name]" ).String ()
711
719
require .Equal (t , sortedNotDeprecated , notSortedNotDeprecated )
@@ -1161,4 +1169,13 @@ func TestCoreHavingIncompatibleDepTools(t *testing.T) {
1161
1169
require .NoError (t , err )
1162
1170
requirejson .Query (t , stdout , `.[] | select(.id == "foo_vendor:avr") | .latest` , `"1.0.1"` )
1163
1171
requirejson .Query (t , stdout , `.[] | select(.id == "incompatible_vendor:avr") | .incompatible` , `true` )
1172
+
1173
+ // In text mode, core search doesn't show any version if no compatible one are present
1174
+ stdout , _ , err = cli .Run ("core" , "search" , additionalURLs )
1175
+ require .NoError (t , err )
1176
+ var lines [][]string
1177
+ for _ , v := range strings .Split (strings .TrimSpace (string (stdout )), "\n " ) {
1178
+ lines = append (lines , strings .Fields (strings .TrimSpace (v )))
1179
+ }
1180
+ require .Contains (t , lines , []string {"incompatible_vendor:avr" , "Incompatible" , "Boards" })
1164
1181
}
0 commit comments