github.com/mckael/restic@v0.8.3/internal/backend/gs/config_test.go (about)

     1  package gs
     2  
     3  import "testing"
     4  
     5  var configTests = []struct {
     6  	s   string
     7  	cfg Config
     8  }{
     9  	{"gs:bucketname:/", Config{
    10  		Bucket:      "bucketname",
    11  		Prefix:      "",
    12  		Connections: 5,
    13  	}},
    14  	{"gs:bucketname:/prefix/directory", Config{
    15  		Bucket:      "bucketname",
    16  		Prefix:      "prefix/directory",
    17  		Connections: 5,
    18  	}},
    19  	{"gs:bucketname:/prefix/directory/", Config{
    20  		Bucket:      "bucketname",
    21  		Prefix:      "prefix/directory",
    22  		Connections: 5,
    23  	}},
    24  }
    25  
    26  func TestParseConfig(t *testing.T) {
    27  	for i, test := range configTests {
    28  		cfg, err := ParseConfig(test.s)
    29  		if err != nil {
    30  			t.Errorf("test %d:%s failed: %v", i, test.s, err)
    31  			continue
    32  		}
    33  
    34  		if cfg != test.cfg {
    35  			t.Errorf("test %d:\ninput:\n  %s\n wrong config, want:\n  %v\ngot:\n  %v",
    36  				i, test.s, test.cfg, cfg)
    37  			continue
    38  		}
    39  	}
    40  }