fs: fix option types printing incorrectly for backend flags

Before this change backend types were printing incorrectly as the name
of the type, not what was defined by the Type() method.

This was not working due to not calling the Type() method. However
this needed to be defined on a non-pointer type due to the way the
options are handled.
This commit is contained in:
Nick Craig-Wood
2023-09-27 13:58:27 +01:00
parent b8591b230d
commit 3553cc4a5f
15 changed files with 73 additions and 26 deletions

View File

@ -17,8 +17,20 @@ type flagger interface {
json.Unmarshaler
}
// Check it satisfies the interface
var _ flagger = (*SizeSuffix)(nil)
// Interface which non-pointer flags must satisfy
//
// These are from pflag.Value and need to be non-pointer due the the
// way the backend flags are inserted into the flags.
type flaggerNP interface {
String() string
Type() string
}
// Check it satisfies the interfaces
var (
_ flagger = (*SizeSuffix)(nil)
_ flaggerNP = SizeSuffix(0)
)
func TestSizeSuffixString(t *testing.T) {
for _, test := range []struct {