Skip to content

Commit

Permalink
add tests for isUpgrade/isDowngrade
Browse files Browse the repository at this point in the history
  • Loading branch information
dcrosta committed Oct 7, 2024
1 parent 0ca97a4 commit fee94b7
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions internal/provider/cluster_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1449,3 +1449,61 @@ func TestClusterSchemaInSync(t *testing.T) {
dAttrs := dSchema.Schema.Attributes
CheckSchemaAttributesMatch(t, rAttrs, dAttrs)
}

func TestIsUpgrade(t *testing.T) {
_, err := isUpgrade("v22.2", "foo")
require.Error(t, err)

upgrade, err := isUpgrade("v24.1", "v24.2")
require.NoError(t, err)
require.True(t, upgrade)

upgrade, err = isUpgrade("v24.1", "v24.3")
require.NoError(t, err)
require.True(t, upgrade)

upgrade, err = isUpgrade("v23.2", "v24.1")
require.NoError(t, err)
require.True(t, upgrade)

upgrade, err = isUpgrade("v24.2", "v24.2")
require.NoError(t, err)
require.False(t, upgrade)

upgrade, err = isUpgrade("v24.2", "v24.1")
require.NoError(t, err)
require.False(t, upgrade)

upgrade, err = isUpgrade("v24.2", "v23.2")
require.NoError(t, err)
require.False(t, upgrade)
}

func TestIsDowngrade(t *testing.T) {
_, err := isDowngrade("v22.2", "foo")
require.Error(t, err)

upgrade, err := isDowngrade("v24.2", "v24.1")
require.NoError(t, err)
require.True(t, upgrade)

upgrade, err = isDowngrade("v24.2", "v23.2")
require.NoError(t, err)
require.True(t, upgrade)

upgrade, err = isDowngrade("v24.2", "v24.2")
require.NoError(t, err)
require.False(t, upgrade)

upgrade, err = isDowngrade("v24.1", "v24.2")
require.NoError(t, err)
require.False(t, upgrade)

upgrade, err = isDowngrade("v24.1", "v24.3")
require.NoError(t, err)
require.False(t, upgrade)

upgrade, err = isDowngrade("v23.2", "v24.1")
require.NoError(t, err)
require.False(t, upgrade)
}

0 comments on commit fee94b7

Please sign in to comment.