Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Unified Diff: go/src/infra/tools/cipd/common/common_test.go

Issue 1129043003: cipd: Refactor client to make it more readable. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « go/src/infra/tools/cipd/common/common.infra_testing ('k') | go/src/infra/tools/cipd/common_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: go/src/infra/tools/cipd/common/common_test.go
diff --git a/go/src/infra/tools/cipd/common_test.go b/go/src/infra/tools/cipd/common/common_test.go
similarity index 72%
rename from go/src/infra/tools/cipd/common_test.go
rename to go/src/infra/tools/cipd/common/common_test.go
index c0bd2d8c2e627b6595c0795c72b4e6f74d554704..2f917a1e14e2bbcd992aa29b9a4263db222fa1ab 100644
--- a/go/src/infra/tools/cipd/common_test.go
+++ b/go/src/infra/tools/cipd/common/common_test.go
@@ -2,48 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-package cipd
+package common
import (
- "bytes"
+ "fmt"
"strings"
"testing"
. "github.com/smartystreets/goconvey/convey"
)
-func TestReadManifest(t *testing.T) {
- var goodManifest = `{
- "format_version": "1",
- "package_name": "package/name"
-}`
-
- Convey("readManifest can read valid manifest", t, func() {
- manifest, err := readManifest(strings.NewReader(goodManifest))
- So(manifest, ShouldResemble, Manifest{
- FormatVersion: "1",
- PackageName: "package/name",
- })
- So(err, ShouldBeNil)
- })
-
- Convey("readManifest rejects invalid manifest", t, func() {
- manifest, err := readManifest(strings.NewReader("I'm not a manifest"))
- So(manifest, ShouldResemble, Manifest{})
- So(err, ShouldNotBeNil)
- })
-
- Convey("writeManifest works", t, func() {
- buf := &bytes.Buffer{}
- m := Manifest{
- FormatVersion: "1",
- PackageName: "package/name",
- }
- So(writeManifest(&m, buf), ShouldBeNil)
- So(string(buf.Bytes()), ShouldEqual, goodManifest)
- })
-}
-
func TestValidatePackageName(t *testing.T) {
Convey("ValidatePackageName works", t, func() {
So(ValidatePackageName("good/name"), ShouldBeNil)
@@ -85,3 +53,20 @@ func TestValidateInstanceTag(t *testing.T) {
So(ValidateInstanceTag("good_tag:asdad/asdad/adad/a\\asdasdad"), ShouldBeNil)
})
}
+
+func TestValidatePin(t *testing.T) {
+ Convey("TestValidatePin works", t, func() {
+ So(ValidatePin(Pin{"good/name", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}), ShouldBeNil)
+ So(ValidatePin(Pin{"BAD/name", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}), ShouldNotBeNil)
+ So(ValidatePin(Pin{"good/name", "aaaaaaaaaaa"}), ShouldNotBeNil)
+ })
+}
+
+func TestPinToString(t *testing.T) {
+ Convey("Pin.String works", t, func() {
+ So(
+ fmt.Sprintf("%s", Pin{"good/name", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}),
+ ShouldEqual,
+ "good/name:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
+ })
+}
« no previous file with comments | « go/src/infra/tools/cipd/common/common.infra_testing ('k') | go/src/infra/tools/cipd/common_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698