github.com/mckael/restic@v0.8.3/internal/backend/rest/config_test.go (about) 1 package rest 2 3 import ( 4 "net/url" 5 "reflect" 6 "testing" 7 ) 8 9 func parseURL(s string) *url.URL { 10 u, err := url.Parse(s) 11 if err != nil { 12 panic(err) 13 } 14 15 return u 16 } 17 18 var configTests = []struct { 19 s string 20 cfg Config 21 }{ 22 {"rest:http://localhost:1234", Config{ 23 URL: parseURL("http://localhost:1234"), 24 Connections: 5, 25 }}, 26 } 27 28 func TestParseConfig(t *testing.T) { 29 for i, test := range configTests { 30 cfg, err := ParseConfig(test.s) 31 if err != nil { 32 t.Errorf("test %d:%s failed: %v", i, test.s, err) 33 continue 34 } 35 36 if !reflect.DeepEqual(cfg, test.cfg) { 37 t.Errorf("test %d:\ninput:\n %s\n wrong config, want:\n %v\ngot:\n %v", 38 i, test.s, test.cfg, cfg) 39 continue 40 } 41 } 42 }