mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-21 07:56:26 +01:00
9a63f6c1b8
* {vmbackup, vmbackup/snapshot}: validate snapshot name * vmbackup/snapshot: added another checks * backup/actions: added check that we ignore backup_complete.ignore file * vmbackup: moved snapshot to lib directory * lib/snapshot: added functions description * lib/snapshot: fixed typo * vmbackup: code cleanup * wip * vmbackup: Prevent save backups to the same folder where TSDB data is * Apply suggestions from code review * wip * wip * wip Co-authored-by: Aliaksandr Valialkin <valyala@victoriametrics.com>
30 lines
852 B
Go
30 lines
852 B
Go
package main
|
|
|
|
import (
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestHasFilepathPrefix(t *testing.T) {
|
|
f := func(dst, storageDataPath string, resultExpected bool) {
|
|
t.Helper()
|
|
result := hasFilepathPrefix(dst, storageDataPath)
|
|
if result != resultExpected {
|
|
t.Errorf("unexpected hasFilepathPrefix(%q, %q); got: %v; want: %v", dst, storageDataPath, result, resultExpected)
|
|
}
|
|
}
|
|
pwd, err := filepath.Abs("")
|
|
if err != nil {
|
|
t.Fatalf("cannot determine working directory: %s", err)
|
|
}
|
|
f("s3://foo/bar", "foo", false)
|
|
f("fs://"+pwd+"/foo", "foo", true)
|
|
f("fs://"+pwd+"/foo", "foo/bar", false)
|
|
f("fs://"+pwd+"/foo/bar", "foo", true)
|
|
f("fs://"+pwd+"/foo", "bar", false)
|
|
f("fs://"+pwd+"/foo", pwd+"/foo", true)
|
|
f("fs://"+pwd+"/foo", pwd+"/foo/bar", false)
|
|
f("fs://"+pwd+"/foo/bar", pwd+"/foo", true)
|
|
f("fs://"+pwd+"/foo", pwd+"/bar", false)
|
|
}
|