mirror of
https://github.com/octoleo/restic.git
synced 2024-12-22 10:58:55 +00:00
Use flag instead of build tag to run integration tests
This commit is contained in:
parent
7c107acf0b
commit
12677b4f8a
4
Makefile
4
Makefile
@ -50,15 +50,15 @@ gox: .gopath $(SOURCE)
|
|||||||
|
|
||||||
test-integration: .gopath
|
test-integration: .gopath
|
||||||
cd $(BASEPATH) && go test $(GOTESTFLAGS) \
|
cd $(BASEPATH) && go test $(GOTESTFLAGS) \
|
||||||
-tags integration \
|
|
||||||
./backend \
|
./backend \
|
||||||
-cover -covermode=count -coverprofile=integration-sftp.cov \
|
-cover -covermode=count -coverprofile=integration-sftp.cov \
|
||||||
|
-test.integration \
|
||||||
-test.sftppath=$(SFTP_PATH)
|
-test.sftppath=$(SFTP_PATH)
|
||||||
|
|
||||||
cd $(BASEPATH) && go test $(GOTESTFLAGS) \
|
cd $(BASEPATH) && go test $(GOTESTFLAGS) \
|
||||||
-tags integration \
|
|
||||||
./cmd/restic \
|
./cmd/restic \
|
||||||
-cover -covermode=count -coverprofile=integration.cov \
|
-cover -covermode=count -coverprofile=integration.cov \
|
||||||
|
-test.integration \
|
||||||
-test.datafile=$(PWD)/testsuite/fake-data.tar.gz
|
-test.datafile=$(PWD)/testsuite/fake-data.tar.gz
|
||||||
|
|
||||||
all.cov: .gopath $(SOURCE) test-integration
|
all.cov: .gopath $(SOURCE) test-integration
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build integration
|
|
||||||
|
|
||||||
package backend_test
|
package backend_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -37,6 +35,10 @@ func teardownSFTPBackend(t *testing.T, b *sftp.SFTP) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSFTPBackend(t *testing.T) {
|
func TestSFTPBackend(t *testing.T) {
|
||||||
|
if !*RunIntegrationTest {
|
||||||
|
t.Skip("integration tests disabled, use `-test.integration` to enable")
|
||||||
|
}
|
||||||
|
|
||||||
if *sftpPath == "" {
|
if *sftpPath == "" {
|
||||||
t.Skipf("sftppath not set, skipping TestSFTPBackend")
|
t.Skipf("sftppath not set, skipping TestSFTPBackend")
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build integration
|
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// +build integration
|
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -119,8 +117,12 @@ func cmdFsck(t testing.TB) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestBackup(t *testing.T) {
|
func TestBackup(t *testing.T) {
|
||||||
|
if !*RunIntegrationTest {
|
||||||
|
t.Skip("integration tests disabled, use `-test.integration` to enable")
|
||||||
|
}
|
||||||
|
|
||||||
if *TestDataFile == "" {
|
if *TestDataFile == "" {
|
||||||
t.Fatal("no data tar file specified, use flag '-test.datafile'")
|
t.Fatal("no data tar file specified, use flag `-test.datafile`")
|
||||||
}
|
}
|
||||||
|
|
||||||
tempdir := setupTempdir(t)
|
tempdir := setupTempdir(t)
|
||||||
|
@ -12,9 +12,12 @@ import (
|
|||||||
"github.com/restic/restic/repository"
|
"github.com/restic/restic/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
var TestPassword = flag.String("test.password", "geheim", `use this password for repositories created during tests (default: "geheim")`)
|
var (
|
||||||
var TestCleanup = flag.Bool("test.cleanup", true, "clean up after running tests (remove local backend directory with all content)")
|
TestPassword = flag.String("test.password", "geheim", `use this password for repositories created during tests (default: "geheim")`)
|
||||||
var TestTempDir = flag.String("test.tempdir", "", "use this directory for temporary storage (default: system temp dir)")
|
TestCleanup = flag.Bool("test.cleanup", true, "clean up after running tests (remove local backend directory with all content)")
|
||||||
|
TestTempDir = flag.String("test.tempdir", "", "use this directory for temporary storage (default: system temp dir)")
|
||||||
|
RunIntegrationTest = flag.Bool("test.integration", false, "run integration tests (default: false)")
|
||||||
|
)
|
||||||
|
|
||||||
func SetupRepo(t testing.TB) *repository.Repository {
|
func SetupRepo(t testing.TB) *repository.Repository {
|
||||||
tempdir, err := ioutil.TempDir(*TestTempDir, "restic-test-")
|
tempdir, err := ioutil.TempDir(*TestTempDir, "restic-test-")
|
||||||
|
Loading…
Reference in New Issue
Block a user