Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New error for VG-removeMember #139

Merged
merged 1 commit into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions gopowerstore_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package gopowerstore

import (
"net/http"
"strings"

"github.com/dell/gopowerstore/api"
)
Expand Down Expand Up @@ -134,6 +135,11 @@ func (err *APIError) ReplicationSessionAlreadyCreated() bool {
return err.StatusCode == http.StatusBadRequest
}

// VolumeAlreadyRemovedFromVolumeGroup returns true if API error indicate that volume is not part of the volume group
func (err *APIError) VolumeAlreadyRemovedFromVolumeGroup() bool {
return err.StatusCode == http.StatusUnprocessableEntity && strings.Contains(err.Message, "not part")
}

// NewNotFoundError returns new VolumeIsNotExistError
func NewNotFoundError() APIError {
return notFoundError()
Expand Down
13 changes: 13 additions & 0 deletions gopowerstore_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,16 @@ func TestAPIError_ReplicationSessionAlreadyCreated(t *testing.T) {
apiError.StatusCode = http.StatusBadRequest
assert.True(t, apiError.ReplicationSessionAlreadyCreated())
}

func TestAPIError_VolumeAlreadyRemovedFromVolumeGroup(t *testing.T) {
apiError := NewAPIError()
apiError.StatusCode = http.StatusBadRequest
assert.False(t, apiError.VolumeAlreadyRemovedFromVolumeGroup())

apiError.StatusCode = http.StatusUnprocessableEntity
assert.False(t, apiError.VolumeAlreadyRemovedFromVolumeGroup())

apiError.StatusCode = http.StatusUnprocessableEntity
apiError.Message = "One or more volumes to be removed are not part of the volume group"
assert.True(t, apiError.VolumeAlreadyRemovedFromVolumeGroup())
}
1 change: 1 addition & 0 deletions replication_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const (
RsStatePaused RSStateEnum = "Paused"
RsStatePausedForMigration RSStateEnum = "Paused_For_Migration"
RsStatePausedForNdu RSStateEnum = "Paused_For_NDU"
RsStateFractured RSStateEnum = "Fractured"
RsStateResuming RSStateEnum = "Resuming"
RsStateFailingOver RSStateEnum = "Failing_Over"
RsStateFailingOverForDR RSStateEnum = "Failing_Over_For_DR"
Expand Down