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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package internal
6
7 import (
8 "testing"
9
10 "infra/tools/cipd/internal/messages"
11
12 . "github.com/smartystreets/goconvey/convey"
13 )
14
15 func TestChecksumCheckingWorks(t *testing.T) {
16 msg := messages.TagCache{
17 Entries: []*messages.TagCache_Entry{
18 &messages.TagCache_Entry{
19 Package: strPtr("package"),
20 Tag: strPtr("tag"),
21 InstanceId: strPtr("instance_id"),
22 },
23 },
24 }
25
26 Convey("Works", t, func(c C) {
27 buf, err := MarshalWithSHA1(&msg)
28 So(err, ShouldBeNil)
29 out := messages.TagCache{}
30 So(UnmarshalWithSHA1(buf, &out), ShouldBeNil)
31 So(out, ShouldResemble, msg)
32 })
33
34 Convey("Rejects bad msg", t, func(c C) {
35 buf, err := MarshalWithSHA1(&msg)
36 So(err, ShouldBeNil)
37 buf[10] = 0
38 out := messages.TagCache{}
39 So(UnmarshalWithSHA1(buf, &out), ShouldNotBeNil)
40 })
41 }
42
43 func strPtr(s string) *string {
44 return &s
45 }
OLDNEW
« 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