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

Side by Side Diff: vpython/spec/spec_test.go

Issue 2705623003: vpython: Add environment spec package. (Closed)
Patch Set: env to vpython, comments Created 3 years, 10 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
« no previous file with comments | « vpython/spec/spec.go ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 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 spec
6
7 import (
8 "testing"
9
10 "github.com/luci/luci-go/vpython/api/vpython"
11
12 . "github.com/luci/luci-go/common/testing/assertions"
13 . "github.com/smartystreets/goconvey/convey"
14 )
15
16 func TestNormalizeAndHash(t *testing.T) {
17 t.Parallel()
18
19 pkgFoo := &vpython.Spec_Package{Path: "foo", Version: "1"}
20 pkgBar := &vpython.Spec_Package{Path: "bar", Version: "2"}
21 pkgBaz := &vpython.Spec_Package{Path: "baz", Version: "3"}
22
23 Convey(`Test manifest generation`, t, func() {
24 var spec vpython.Spec
25
26 Convey(`Will normalize an empty spec`, func() {
27 So(Normalize(&spec), ShouldBeNil)
28 So(spec, ShouldResemble, vpython.Spec{})
29 })
30
31 Convey(`Will normalize to sorted order.`, func() {
32 spec.Wheel = []*vpython.Spec_Package{pkgFoo, pkgBar, pkg Baz}
33 So(Normalize(&spec), ShouldBeNil)
34 So(spec, ShouldResemble, vpython.Spec{
35 Wheel: []*vpython.Spec_Package{pkgBar, pkgBaz, p kgFoo},
36 })
37
38 So(Hash(&spec), ShouldEqual, "904b958b73206e64ce267e2b6d f5fa0f1223e348327dba5e9a5f6421bb42cadb")
39 })
40
41 Convey(`Will fail to normalize if there are duplicate wheels.`, func() {
42 spec.Wheel = []*vpython.Spec_Package{pkgFoo, pkgFoo, pkg Bar, pkgBaz}
43 So(Normalize(&spec), ShouldErrLike, "duplicate spec entr ies")
44
45 // Even if the versions differ.
46 fooClone := *pkgFoo
47 fooClone.Version = "other"
48 spec.Wheel = []*vpython.Spec_Package{pkgFoo, &fooClone, pkgBar, pkgBaz}
49 So(Normalize(&spec), ShouldErrLike, "duplicate spec entr ies")
50 })
51 })
52 }
OLDNEW
« no previous file with comments | « vpython/spec/spec.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698