mirror of
https://github.com/rclone/rclone.git
synced 2025-12-11 22:14:05 +01:00
config: Improve the Provider matching to have a negated match #2140
This makes it easier to make classes of provider in the config.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
@@ -205,3 +206,24 @@ func hashedKeyCompare(t *testing.T, a, b string, shouldMatch bool) {
|
||||
assert.NotEqual(t, k1, k2)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMatchProvider(t *testing.T) {
|
||||
for _, test := range []struct {
|
||||
config string
|
||||
provider string
|
||||
want bool
|
||||
}{
|
||||
{"", "", true},
|
||||
{"one", "one", true},
|
||||
{"one,two", "two", true},
|
||||
{"one,two,three", "two", true},
|
||||
{"one", "on", false},
|
||||
{"one,two,three", "tw", false},
|
||||
{"!one,two,three", "two", false},
|
||||
{"!one,two,three", "four", true},
|
||||
} {
|
||||
what := fmt.Sprintf("%q,%q", test.config, test.provider)
|
||||
got := matchProvider(test.config, test.provider)
|
||||
assert.Equal(t, test.want, got, what)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user