features: add tests

This commit is contained in:
Michael Eischer 2024-02-12 21:34:37 +01:00
parent 1c77c51a03
commit 70839155f2
2 changed files with 158 additions and 0 deletions

View file

@ -0,0 +1,19 @@
package feature_test
import (
"testing"
"github.com/restic/restic/internal/feature"
rtest "github.com/restic/restic/internal/test"
)
func TestSetFeatureFlag(t *testing.T) {
flags := buildTestFlagSet()
rtest.Assert(t, !flags.Enabled(alpha), "expected alpha feature to be disabled")
restore := feature.TestSetFlag(t, flags, alpha, true)
rtest.Assert(t, flags.Enabled(alpha), "expected alpha feature to be enabled")
restore()
rtest.Assert(t, !flags.Enabled(alpha), "expected alpha feature to be disabled again")
}