mirror of
https://github.com/rclone/rclone.git
synced 2025-08-14 07:49:00 +02:00
fs: re-implement CutoffMode, LogLevel, TerminalColorMode with Enum
This almost 100% backwards compatible. The only difference being that in the rc options/get output CutoffMode, LogLevel, TerminalColorMode will be output as strings instead of integers. This is a lot more convenient for the user. They still accept integer inputs though so the fallout from this should be minimal.
This commit is contained in:
@ -107,16 +107,20 @@ func TestEnumUnmarshalJSON(t *testing.T) {
|
||||
for _, test := range []struct {
|
||||
in string
|
||||
want choice
|
||||
err bool
|
||||
err string
|
||||
}{
|
||||
{`"A"`, choiceA, false},
|
||||
{`"B"`, choiceB, false},
|
||||
{`"D"`, choice(0), true},
|
||||
{`"A"`, choiceA, ""},
|
||||
{`"B"`, choiceB, ""},
|
||||
{`0`, choiceA, ""},
|
||||
{`1`, choiceB, ""},
|
||||
{`"D"`, choice(0), `invalid choice "D" from: A, B, C`},
|
||||
{`100`, choice(0), `100 is out of range: must be 0..3`},
|
||||
} {
|
||||
var got choice
|
||||
err := json.Unmarshal([]byte(test.in), &got)
|
||||
if test.err {
|
||||
if test.err != "" {
|
||||
require.Error(t, err, test.in)
|
||||
assert.ErrorContains(t, err, test.err)
|
||||
} else {
|
||||
require.NoError(t, err, test.in)
|
||||
}
|
||||
|
Reference in New Issue
Block a user