From efe0ca527346937badc39b649d032e8e4a33fcd7 Mon Sep 17 00:00:00 2001 From: Stefan Scherer Date: Fri, 9 Jun 2017 12:41:36 +0200 Subject: [PATCH] Fix versioncmp for ce edition Signed-off-by: Stefan Scherer --- libmachine/versioncmp/compare.go | 4 ++-- libmachine/versioncmp/compare_test.go | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/libmachine/versioncmp/compare.go b/libmachine/versioncmp/compare.go index 1465d0fd..83c9a63a 100644 --- a/libmachine/versioncmp/compare.go +++ b/libmachine/versioncmp/compare.go @@ -29,10 +29,10 @@ func compare(v1, v2 string) int { // presence of the "ce" string in the version string) are "less than" // any community edition release (first occuring in March 2017). if strings.Contains(v1, ceEdition) && !strings.Contains(v2, ceEdition) { - return -1 + return 1 } if !strings.Contains(v1, ceEdition) && strings.Contains(v2, ceEdition) { - return 1 + return -1 } // Without this tag, both are pre-CE versions. diff --git a/libmachine/versioncmp/compare_test.go b/libmachine/versioncmp/compare_test.go index d1ae8370..1840aacf 100644 --- a/libmachine/versioncmp/compare_test.go +++ b/libmachine/versioncmp/compare_test.go @@ -33,6 +33,8 @@ func TestCompare(t *testing.T) { {"17.03.0-ce", "17.06.0-ce", -1}, {"17.03.0-ce-rc2", "17.03.0-ce-rc1", 1}, {"17.03.0-ce-rc1", "18.03.0-ce-rc1", -1}, + {"17.06.0-ce-rc2", "1.12.0", 1}, + {"1.12.0", "17.06.0-ce-rc2", -1}, } for _, tc := range cases {