From 51885f087553014a7863bacc0001283832483fb4 Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Wed, 17 Mar 2021 16:07:18 -0400 Subject: [PATCH] rbd: add test case for Stringer supporting mirroring constants Signed-off-by: John Mulligan --- rbd/mirror_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/rbd/mirror_test.go b/rbd/mirror_test.go index a8eb8e0..8a77a72 100644 --- a/rbd/mirror_test.go +++ b/rbd/mirror_test.go @@ -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), ""}, + {ImageMirrorModeJournal, "journal"}, + {ImageMirrorModeSnapshot, "snapshot"}, + {ImageMirrorMode(9999), ""}, + {MirrorImageDisabling, "disabling"}, + {MirrorImageEnabled, "enabled"}, + {MirrorImageDisabled, "disabled"}, + {MirrorImageState(9999), ""}, + } + for _, v := range x { + assert.Equal(t, v.s.String(), v.t) + } +}