| OLD | NEW |
| (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 cipd |
| 6 |
| 7 import ( |
| 8 "bytes" |
| 9 "testing" |
| 10 |
| 11 "github.com/luci/luci-go/vpython/api/env" |
| 12 |
| 13 . "github.com/smartystreets/goconvey/convey" |
| 14 ) |
| 15 |
| 16 func TestWriteEnsureFile(t *testing.T) { |
| 17 t.Parallel() |
| 18 |
| 19 Convey(`Test manifest generation`, t, func() { |
| 20 var buf bytes.Buffer |
| 21 |
| 22 Convey(`Invalid packages will panic.`, func() { |
| 23 pkg := &env.Spec_Package{ |
| 24 Path: "foo/bar", |
| 25 } |
| 26 So(validatePackage(pkg), ShouldNotBeNil) |
| 27 So(func() { |
| 28 _ = writeEnsureFile(&buf, []*env.Spec_Package{pk
g}) |
| 29 }, ShouldPanic) |
| 30 }) |
| 31 |
| 32 Convey(`Can write a manifest for packages`, func() { |
| 33 err := writeEnsureFile(&buf, []*env.Spec_Package{ |
| 34 &env.Spec_Package{"foo/bar", "baz"}, |
| 35 &env.Spec_Package{"pants", "key:value"}, |
| 36 }) |
| 37 So(err, ShouldBeNil) |
| 38 So(buf.String(), ShouldResemble, "foo/bar baz\npants key
:value\n") |
| 39 }) |
| 40 }) |
| 41 } |
| OLD | NEW |