mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-14 02:43:36 +00:00
cleanup: move ShouldRetryVolumeGeneration from internal/rbd to internal/util
Signed-off-by: Praveen M <m.praveen@ibm.com>
This commit is contained in:
@ -23,11 +23,8 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/ceph/go-ceph/rados"
|
||||
librbd "github.com/ceph/go-ceph/rbd"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/ceph/ceph-csi/internal/util"
|
||||
)
|
||||
|
||||
func TestHasSnapshotFeature(t *testing.T) {
|
||||
@ -390,54 +387,3 @@ func Test_checkValidImageFeatures(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func Test_shouldRetryVolumeGeneration(t *testing.T) {
|
||||
t.Parallel()
|
||||
type args struct {
|
||||
err error
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want bool
|
||||
}{
|
||||
{
|
||||
name: "No error (stop searching)",
|
||||
args: args{err: nil},
|
||||
want: false, // No error, stop searching
|
||||
},
|
||||
{
|
||||
name: "ErrKeyNotFound (continue searching)",
|
||||
args: args{err: util.ErrKeyNotFound},
|
||||
want: true, // Known error, continue searching
|
||||
},
|
||||
{
|
||||
name: "ErrPoolNotFound (continue searching)",
|
||||
args: args{err: util.ErrPoolNotFound},
|
||||
want: true, // Known error, continue searching
|
||||
},
|
||||
{
|
||||
name: "ErrImageNotFound (continue searching)",
|
||||
args: args{err: util.ErrImageNotFound},
|
||||
want: true, // Known error, continue searching
|
||||
},
|
||||
{
|
||||
name: "ErrPermissionDenied (continue searching)",
|
||||
args: args{err: rados.ErrPermissionDenied},
|
||||
want: true, // Known error, continue searching
|
||||
},
|
||||
{
|
||||
name: "Different error (stop searching)",
|
||||
args: args{err: errors.New("unknown error")},
|
||||
want: false, // Unknown error, stop searching
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
if got := shouldRetryVolumeGeneration(tt.args.err); got != tt.want {
|
||||
t.Errorf("shouldRetryVolumeGeneration() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user