mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-24 19:30:06 +01:00
14c20c1843
* vmalert: support object storage for rules Support loading of alerting and recording rules from object storages `gcs://`, `gs://`, `s3://`. * review fixes
40 lines
849 B
Go
40 lines
849 B
Go
package config
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestNewFS(t *testing.T) {
|
|
f := func(path, expStr string) {
|
|
t.Helper()
|
|
fs, err := newFS(path)
|
|
if err != nil {
|
|
t.Fatalf("unexpected err: %s", err)
|
|
}
|
|
if fs.String() != expStr {
|
|
t.Fatalf("expected FS %q; got %q", expStr, fs.String())
|
|
}
|
|
}
|
|
|
|
f("/foo/bar", "Local FS{MatchPattern: \"/foo/bar\"}")
|
|
f("fs:///foo/bar", "Local FS{MatchPattern: \"/foo/bar\"}")
|
|
}
|
|
|
|
func TestNewFSNegative(t *testing.T) {
|
|
f := func(path, expErr string) {
|
|
t.Helper()
|
|
_, err := newFS(path)
|
|
if err == nil {
|
|
t.Fatalf("expected to have err: %s", expErr)
|
|
}
|
|
if !strings.Contains(err.Error(), expErr) {
|
|
t.Fatalf("expected to have err %q; got %q instead", expErr, err)
|
|
}
|
|
}
|
|
|
|
f("", "path cannot be empty")
|
|
f("fs://", "path cannot be empty")
|
|
f("foobar://baz", `unsupported scheme "foobar"`)
|
|
}
|