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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « vpython/spec/spec.go ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: vpython/spec/spec_test.go
diff --git a/vpython/spec/spec_test.go b/vpython/spec/spec_test.go
new file mode 100644
index 0000000000000000000000000000000000000000..57cafe75a7745fa95473e768dcc7cc07edf66cd6
--- /dev/null
+++ b/vpython/spec/spec_test.go
@@ -0,0 +1,52 @@
+// Copyright 2017 The LUCI Authors. All rights reserved.
+// Use of this source code is governed under the Apache License, Version 2.0
+// that can be found in the LICENSE file.
+
+package spec
+
+import (
+ "testing"
+
+ "github.com/luci/luci-go/vpython/api/vpython"
+
+ . "github.com/luci/luci-go/common/testing/assertions"
+ . "github.com/smartystreets/goconvey/convey"
+)
+
+func TestNormalizeAndHash(t *testing.T) {
+ t.Parallel()
+
+ pkgFoo := &vpython.Spec_Package{Path: "foo", Version: "1"}
+ pkgBar := &vpython.Spec_Package{Path: "bar", Version: "2"}
+ pkgBaz := &vpython.Spec_Package{Path: "baz", Version: "3"}
+
+ Convey(`Test manifest generation`, t, func() {
+ var spec vpython.Spec
+
+ Convey(`Will normalize an empty spec`, func() {
+ So(Normalize(&spec), ShouldBeNil)
+ So(spec, ShouldResemble, vpython.Spec{})
+ })
+
+ Convey(`Will normalize to sorted order.`, func() {
+ spec.Wheel = []*vpython.Spec_Package{pkgFoo, pkgBar, pkgBaz}
+ So(Normalize(&spec), ShouldBeNil)
+ So(spec, ShouldResemble, vpython.Spec{
+ Wheel: []*vpython.Spec_Package{pkgBar, pkgBaz, pkgFoo},
+ })
+
+ So(Hash(&spec), ShouldEqual, "904b958b73206e64ce267e2b6df5fa0f1223e348327dba5e9a5f6421bb42cadb")
+ })
+
+ Convey(`Will fail to normalize if there are duplicate wheels.`, func() {
+ spec.Wheel = []*vpython.Spec_Package{pkgFoo, pkgFoo, pkgBar, pkgBaz}
+ So(Normalize(&spec), ShouldErrLike, "duplicate spec entries")
+
+ // Even if the versions differ.
+ fooClone := *pkgFoo
+ fooClone.Version = "other"
+ spec.Wheel = []*vpython.Spec_Package{pkgFoo, &fooClone, pkgBar, pkgBaz}
+ So(Normalize(&spec), ShouldErrLike, "duplicate spec entries")
+ })
+ })
+}
« 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