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

Unified Diff: go/src/infra/tools/cipd/internal/tagcache_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
« no previous file with comments | « go/src/infra/tools/cipd/internal/tagcache.go ('k') | go/src/infra/tools/cipd/local/fs.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: go/src/infra/tools/cipd/internal/tagcache_test.go
diff --git a/go/src/infra/tools/cipd/internal/tagcache_test.go b/go/src/infra/tools/cipd/internal/tagcache_test.go
new file mode 100644
index 0000000000000000000000000000000000000000..49232ff90ee9a2e39bb5aee2dd2a6832ac316cd2
--- /dev/null
+++ b/go/src/infra/tools/cipd/internal/tagcache_test.go
@@ -0,0 +1,54 @@
+// 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 (
+ "strings"
+ "testing"
+
+ . "github.com/smartystreets/goconvey/convey"
+ "infra/tools/cipd/common"
+)
+
+func TestTagCacheWorks(t *testing.T) {
+ Convey("Works", t, func(c C) {
+ tc := TagCache{}
+ So(tc.ResolveTag("pkg", "tag:1"), ShouldResemble, common.Pin{})
+ So(tc.Dirty(), ShouldBeFalse)
+
+ // Add new.
+ tc.AddTag(common.Pin{
+ PackageName: "pkg",
+ InstanceID: strings.Repeat("a", 40),
+ }, "tag:1")
+ So(tc.Dirty(), ShouldBeTrue)
+ So(tc.ResolveTag("pkg", "tag:1"), ShouldResemble, common.Pin{
+ PackageName: "pkg",
+ InstanceID: strings.Repeat("a", 40),
+ })
+
+ // Replace existing.
+ tc.AddTag(common.Pin{
+ PackageName: "pkg",
+ InstanceID: strings.Repeat("b", 40),
+ }, "tag:1")
+ So(tc.Dirty(), ShouldBeTrue)
+ So(tc.ResolveTag("pkg", "tag:1"), ShouldResemble, common.Pin{
+ PackageName: "pkg",
+ InstanceID: strings.Repeat("b", 40),
+ })
+
+ // Save\load.
+ blob, err := tc.Save()
+ So(err, ShouldBeNil)
+ So(tc.Dirty(), ShouldBeFalse)
+ another := TagCache{}
+ So(another.Load(blob), ShouldBeNil)
+ So(another.ResolveTag("pkg", "tag:1"), ShouldResemble, common.Pin{
+ PackageName: "pkg",
+ InstanceID: strings.Repeat("b", 40),
+ })
+ })
+}
« no previous file with comments | « go/src/infra/tools/cipd/internal/tagcache.go ('k') | go/src/infra/tools/cipd/local/fs.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698