rbd/features: add test for FeatureSet

Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
Niels de Vos 2020-02-20 13:44:40 +01:00 committed by John Mulligan
parent d6a88f65b7
commit a65e39ca3d
1 changed files with 21 additions and 0 deletions

View File

@ -1,6 +1,7 @@
package rbd
import (
"sort"
"testing"
"github.com/stretchr/testify/assert"
@ -49,6 +50,26 @@ func TestGetFeatures(t *testing.T) {
assert.True(t, hasLayering, "FeatureLayering is not set")
assert.True(t, hasStripingV2, "FeatureStripingV2 is not set")
})
t.Run("compareFeatureSet", func(t *testing.T) {
fs := FeatureSet(features)
assert.Contains(t, fs.Names(), FeatureNameLayering)
assert.Contains(t, fs.Names(), FeatureNameStripingV2)
})
}
func TestFeatureSet(t *testing.T) {
fsBits := FeatureSet(FeatureExclusiveLock | FeatureDeepFlatten)
fsNames := FeatureSetFromNames([]string{FeatureNameExclusiveLock, FeatureNameDeepFlatten})
assert.Equal(t, fsBits, fsNames)
fsBitsSorted := fsBits.Names()
sort.Strings(fsBitsSorted)
fsNamesSorted := fsNames.Names()
sort.Strings(fsNamesSorted)
assert.Equal(t, fsBitsSorted, fsNamesSorted)
}
func TestUpdateFeatures(t *testing.T) {