From b1a364ad417cdc9e2f5a213b8ecddf00995a108b Mon Sep 17 00:00:00 2001 From: Artur Souza Date: Fri, 5 Jul 2024 15:12:57 -0300 Subject: [PATCH] Fix check for version to contain scheduler. Signed-off-by: Artur Souza --- pkg/standalone/standalone.go | 6 +++++- pkg/standalone/standalone_test.go | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/pkg/standalone/standalone.go b/pkg/standalone/standalone.go index f25bf9bfb..456ed74aa 100644 --- a/pkg/standalone/standalone.go +++ b/pkg/standalone/standalone.go @@ -176,7 +176,11 @@ func isSchedulerIncluded(runtimeVersion string) (bool, error) { return false, err } - return c.Check(v), nil + vNoPrerelease, err := v.SetPrerelease("") + if err != nil { + return false, err + } + return c.Check(&vNoPrerelease), nil } // Init installs Dapr on a local machine using the supplied runtimeVersion. diff --git a/pkg/standalone/standalone_test.go b/pkg/standalone/standalone_test.go index bf05b1f63..777d42ce2 100644 --- a/pkg/standalone/standalone_test.go +++ b/pkg/standalone/standalone_test.go @@ -334,3 +334,25 @@ func TestInitLogActualContainerRuntimeName(t *testing.T) { }) } } + +func TestIsSchedulerIncluded(t *testing.T) { + scenarios := []struct { + version string + isIncluded bool + }{ + {"1.13.0-rc.1", false}, + {"1.13.0", false}, + {"1.13.1", false}, + {"1.14.0", true}, + {"1.14.0-rc.1", true}, + {"1.14.0-mycompany.1", true}, + {"1.14.1", true}, + } + for _, scenario := range scenarios { + t.Run("isSchedulerIncludedIn"+scenario.version, func(t *testing.T) { + included, err := isSchedulerIncluded(scenario.version) + assert.NoError(t, err) + assert.Equal(t, scenario.isIncluded, included) + }) + } +}