| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 The LUCI Authors. All rights reserved. | |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | |
| 3 // that can be found in the LICENSE file. | |
| 4 | |
| 5 package config | |
| 6 | |
| 7 import ( | |
| 8 "fmt" | |
| 9 "testing" | |
| 10 | |
| 11 . "github.com/luci/luci-go/common/testing/assertions" | |
| 12 . "github.com/smartystreets/goconvey/convey" | |
| 13 ) | |
| 14 | |
| 15 func TestProjectName(t *testing.T) { | |
| 16 t.Parallel() | |
| 17 | |
| 18 Convey(`Testing valid project names`, t, func() { | |
| 19 for _, testCase := range []ProjectName{ | |
| 20 "a", | |
| 21 "foo_bar-baz-059", | |
| 22 } { | |
| 23 Convey(fmt.Sprintf(`Project name %q is valid`, testCase)
, func() { | |
| 24 So(testCase.Validate(), ShouldBeNil) | |
| 25 }) | |
| 26 } | |
| 27 }) | |
| 28 | |
| 29 Convey(`Testing invalid project names`, t, func() { | |
| 30 for _, testCase := range []struct { | |
| 31 v ProjectName | |
| 32 errorsLike string | |
| 33 }{ | |
| 34 {"", "cannot have empty name"}, | |
| 35 {"foo/bar", "invalid character"}, | |
| 36 {"_name", "must begin with a letter"}, | |
| 37 {"1eet", "must begin with a letter"}, | |
| 38 } { | |
| 39 Convey(fmt.Sprintf(`Project name %q fails with error %q`
, testCase.v, testCase.errorsLike), func() { | |
| 40 So(testCase.v.Validate(), ShouldErrLike, testCas
e.errorsLike) | |
| 41 }) | |
| 42 } | |
| 43 }) | |
| 44 } | |
| OLD | NEW |