From ec34da2d6604ed662f0163402d843649b5a1c431 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sun, 21 Feb 2016 15:24:37 +0100 Subject: [PATCH] Add rest backend to location --- src/restic/location/location.go | 2 ++ src/restic/location/location_test.go | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/restic/location/location.go b/src/restic/location/location.go index 8e4a8f1e2..23e0af37b 100644 --- a/src/restic/location/location.go +++ b/src/restic/location/location.go @@ -5,6 +5,7 @@ import ( "strings" "restic/backend/local" + "restic/backend/rest" "restic/backend/s3" "restic/backend/sftp" ) @@ -27,6 +28,7 @@ var parsers = []parser{ {"local", local.ParseConfig}, {"sftp", sftp.ParseConfig}, {"s3", s3.ParseConfig}, + {"rest", rest.ParseConfig}, } // Parse extracts repository location information from the string s. If s diff --git a/src/restic/location/location_test.go b/src/restic/location/location_test.go index 8d9046348..bb4ac64c9 100644 --- a/src/restic/location/location_test.go +++ b/src/restic/location/location_test.go @@ -1,13 +1,24 @@ package location import ( + "net/url" "reflect" "testing" + "restic/backend/rest" "restic/backend/s3" "restic/backend/sftp" ) +func parseURL(s string) *url.URL { + u, err := url.Parse(s) + if err != nil { + panic(err) + } + + return u +} + var parseTests = []struct { s string u Location @@ -101,6 +112,11 @@ var parseTests = []struct { UseHTTP: true, }}, }, + {"rest:http://hostname.foo:1234/", Location{Scheme: "rest", + Config: rest.Config{ + URL: parseURL("http://hostname.foo:1234/"), + }}, + }, } func TestParse(t *testing.T) {