Skip to content

Commit cb32f6d

Browse files
committed
Add test for isRollbackWindowSupported
1 parent 6f4a36c commit cb32f6d

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

internal/pkg/agent/application/upgrade/rollback_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"github.com/elastic/elastic-agent/internal/pkg/agent/application/paths"
2121
"github.com/elastic/elastic-agent/pkg/core/logger"
2222
"github.com/elastic/elastic-agent/pkg/core/logger/loggertest"
23+
"github.com/elastic/elastic-agent/pkg/version"
2324
mocks "github.com/elastic/elastic-agent/testing/mocks/pkg/control/v2/client"
2425
)
2526

@@ -329,6 +330,36 @@ func TestRollback(t *testing.T) {
329330
}
330331
}
331332

333+
func TestIsRollbackWindowSupported(t *testing.T) {
334+
tests := map[string]struct {
335+
version string
336+
want bool
337+
}{
338+
"supported_version": {
339+
version: "9.2.0-SNAPSHOT",
340+
want: true,
341+
},
342+
"older_version": {
343+
version: "9.0.0-SNAPSHOT",
344+
want: false,
345+
},
346+
"exactly_minimum_version": {
347+
version: "9.1.0",
348+
want: true,
349+
},
350+
}
351+
352+
for name, tt := range tests {
353+
t.Run(name, func(t *testing.T) {
354+
v, err := version.ParseVersion(tt.version)
355+
require.NoError(t, err)
356+
357+
got := isRollbackWindowSupported(v)
358+
assert.Equal(t, tt.want, got, "isRollbackWindowSupported(%q)", tt.version)
359+
})
360+
}
361+
}
362+
332363
func TestMakeBaseWatchCmd(t *testing.T) {
333364
exec, err := os.Executable()
334365
require.NoError(t, err)

0 commit comments

Comments
 (0)