| Index: cipd/client/cipd/common/common_test.go
|
| diff --git a/cipd/client/cipd/common/common_test.go b/cipd/client/cipd/common/common_test.go
|
| index 174c4332e597c3d81a9f4fcab1f16fe642adc36f..59069209a78c66350850cf4a17af57a154e197a3 100644
|
| --- a/cipd/client/cipd/common/common_test.go
|
| +++ b/cipd/client/cipd/common/common_test.go
|
| @@ -9,6 +9,7 @@ import (
|
| "strings"
|
| "testing"
|
|
|
| + . "github.com/luci/luci-go/common/testing/assertions"
|
| . "github.com/smartystreets/goconvey/convey"
|
| )
|
|
|
| @@ -80,6 +81,50 @@ func TestValidateInstanceVersion(t *testing.T) {
|
| })
|
| }
|
|
|
| +func TestValidateRoot(t *testing.T) {
|
| + badRoots := []struct {
|
| + name string
|
| + root string
|
| + err string
|
| + }{
|
| + {"windows", "folder\\thing", "backslashes not allowed"},
|
| + {"windows drive", "c:/foo/bar", `colons are not allowed`},
|
| + {"messy", "some/../thing", `"some/../thing" (should be "thing")`},
|
| + {"relative", "../something", `invalid "."`},
|
| + {"single relative", "./something", `"./something" (should be "something")`},
|
| + {"absolute", "/etc", `absolute paths not allowed`},
|
| + {"extra slashes", "//foo/bar", `bad root path`},
|
| + }
|
| +
|
| + goodRoots := []struct {
|
| + name string
|
| + root string
|
| + }{
|
| + {"empty", ""},
|
| + {"simple path", "some/path"},
|
| + {"single path", "something"},
|
| + {"spaces", "some path/with/ spaces"},
|
| + }
|
| +
|
| + Convey("ValidtateRoot", t, func() {
|
| + Convey("rejects bad roots", func() {
|
| + for _, tc := range badRoots {
|
| + Convey(tc.name, func() {
|
| + So(ValidateRoot(tc.root), ShouldErrLike, tc.err)
|
| + })
|
| + }
|
| + })
|
| +
|
| + Convey("accepts good roots", func() {
|
| + for _, tc := range goodRoots {
|
| + Convey(tc.name, func() {
|
| + So(ValidateRoot(tc.root), ShouldErrLike, nil)
|
| + })
|
| + }
|
| + })
|
| + })
|
| +}
|
| +
|
| func TestPinToString(t *testing.T) {
|
| Convey("Pin.String works", t, func() {
|
| So(
|
|
|