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

Unified Diff: go/src/infra/tools/cipd/internal/checksum_test.go

Issue 1381583007: cipd: Implement local cache for ResolveVersion(...) call with tags. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@cipd-init
Patch Set: rebase Created 5 years, 2 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
Index: go/src/infra/tools/cipd/internal/checksum_test.go
diff --git a/go/src/infra/tools/cipd/internal/checksum_test.go b/go/src/infra/tools/cipd/internal/checksum_test.go
new file mode 100644
index 0000000000000000000000000000000000000000..3b307c0def2090889d0580a7fbf0aa40e9275b27
--- /dev/null
+++ b/go/src/infra/tools/cipd/internal/checksum_test.go
@@ -0,0 +1,45 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package internal
+
+import (
+ "testing"
+
+ "infra/tools/cipd/internal/messages"
+
+ . "github.com/smartystreets/goconvey/convey"
+)
+
+func TestChecksumCheckingWorks(t *testing.T) {
+ msg := messages.TagCache{
+ Entries: []*messages.TagCache_Entry{
+ &messages.TagCache_Entry{
+ Package: strPtr("package"),
+ Tag: strPtr("tag"),
+ InstanceId: strPtr("instance_id"),
+ },
+ },
+ }
+
+ Convey("Works", t, func(c C) {
+ buf, err := MarshalWithSHA1(&msg)
+ So(err, ShouldBeNil)
+ out := messages.TagCache{}
+ So(UnmarshalWithSHA1(buf, &out), ShouldBeNil)
+ So(out, ShouldResemble, msg)
+ })
+
+ Convey("Rejects bad msg", t, func(c C) {
+ buf, err := MarshalWithSHA1(&msg)
+ So(err, ShouldBeNil)
+ buf[10] = 0
+ out := messages.TagCache{}
+ So(UnmarshalWithSHA1(buf, &out), ShouldNotBeNil)
+ })
+}
+
+func strPtr(s string) *string {
+ return &s
+}
« no previous file with comments | « go/src/infra/tools/cipd/internal/checksum.go ('k') | go/src/infra/tools/cipd/internal/internal.infra_testing » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698