|
17 | 17 |
|
18 | 18 | package cmd |
19 | 19 |
|
20 | | -import checkv1 "gopkg.in/check.v1" |
| 20 | +import ( |
| 21 | + "testing" |
| 22 | + |
| 23 | + checkv1 "gopkg.in/check.v1" |
| 24 | +) |
21 | 25 |
|
22 | 26 | // TestURL - tests url parsing and fields. |
23 | 27 | func (s *TestSuite) TestURL(c *checkv1.C) { |
@@ -52,3 +56,33 @@ func (s *TestSuite) TestURLJoinPath(c *checkv1.C) { |
52 | 56 | url = urlJoinPath(url1, url2) |
53 | 57 | c.Assert(url, checkv1.Equals, "http://s3.mycompany.io/dev/mybucket/bin/") |
54 | 58 | } |
| 59 | + |
| 60 | +func Test_isURLPrefix(t *testing.T) { |
| 61 | + type args struct { |
| 62 | + src string |
| 63 | + dest string |
| 64 | + } |
| 65 | + tests := []struct { |
| 66 | + name string |
| 67 | + args args |
| 68 | + want bool |
| 69 | + }{ |
| 70 | + {"test1", args{"s3/test", "s3/test/test"}, true}, |
| 71 | + {"test2", args{"s3/test/", "s3/test/test"}, true}, |
| 72 | + {"test3", args{"s3/test/test", "s3/test/"}, true}, |
| 73 | + {"test4", args{"s3/test/test", "s3/test/test.123"}, false}, |
| 74 | + {"test5", args{"s3/test/", "s3/test/test/test/test"}, true}, |
| 75 | + {"test6", args{"s3/test/*", "s3/test/test/"}, true}, |
| 76 | + {"test7", args{"s3/test/*", "s3/test1/test/"}, false}, |
| 77 | + } |
| 78 | + for _, tt := range tests { |
| 79 | + t.Run(tt.name, func(t *testing.T) { |
| 80 | + if got := isURLPrefix(tt.args.src, tt.args.dest); got != tt.want { |
| 81 | + t.Errorf("isURLPrefix() = %v, want %v", got, tt.want) |
| 82 | + } |
| 83 | + if got := isURLPrefix(tt.args.dest, tt.args.src); got != tt.want { |
| 84 | + t.Errorf("isURLPrefix() = %v, want %v", got, tt.want) |
| 85 | + } |
| 86 | + }) |
| 87 | + } |
| 88 | +} |
0 commit comments