mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
2eb9ca1889
* vmalert: support object storage for rules Support loading of alerting and recording rules from object storages `gcs://`, `gs://`, `s3://`. * review fixes
39 lines
849 B
Go
39 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"`)
|
|
}
|