rbd: add test case for Stringer supporting mirroring constants

Signed-off-by: John Mulligan <jmulligan@redhat.com>
This commit is contained in:
John Mulligan 2021-03-17 16:07:18 -04:00 committed by mergify[bot]
parent b614e93b9d
commit 51885f0875
1 changed files with 23 additions and 0 deletions

View File

@ -8,6 +8,7 @@
package rbd
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
@ -239,3 +240,25 @@ func TestGetMirrorImageInfo(t *testing.T) {
assert.Equal(t, mii.Primary, true)
})
}
func TestMirrorConstantStrings(t *testing.T) {
x := []struct {
s fmt.Stringer
t string
}{
{MirrorModeDisabled, "disabled"},
{MirrorModeImage, "image"},
{MirrorModePool, "pool"},
{MirrorMode(9999), "<unknown>"},
{ImageMirrorModeJournal, "journal"},
{ImageMirrorModeSnapshot, "snapshot"},
{ImageMirrorMode(9999), "<unknown>"},
{MirrorImageDisabling, "disabling"},
{MirrorImageEnabled, "enabled"},
{MirrorImageDisabled, "disabled"},
{MirrorImageState(9999), "<unknown>"},
}
for _, v := range x {
assert.Equal(t, v.s.String(), v.t)
}
}