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

Unified Diff: cipd/client/cipd/ensure/file_test.go

Issue 2651863002: Add ensure-file parser package. (Closed)
Patch Set: Address comments Created 3 years, 11 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 | « cipd/client/cipd/ensure/file.go ('k') | cipd/client/cipd/ensure/good_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cipd/client/cipd/ensure/file_test.go
diff --git a/cipd/client/cipd/ensure/file_test.go b/cipd/client/cipd/ensure/file_test.go
new file mode 100644
index 0000000000000000000000000000000000000000..5f2f8dcd6feb7c392092a4f18e9aa3cc70bfa1f6
--- /dev/null
+++ b/cipd/client/cipd/ensure/file_test.go
@@ -0,0 +1,83 @@
+// 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 ensure
+
+import (
+ "bytes"
+ "testing"
+
+ . "github.com/smartystreets/goconvey/convey"
+)
+
+var fileSerializationTests = []struct {
+ name string
+ f *File
+ expect string
+}{
+ {
+ "empty",
+ &File{},
+ f(""),
+ },
+
+ {
+ "ServiceURL",
+ &File{"https://something.example.com", nil},
+ f(
+ "$ServiceURL https://something.example.com",
+ ),
+ },
+
+ {
+ "simple packages",
+ &File{"", map[string]PackageSlice{
+ "": {
+ PackageDef{"some/thing", "version", 0},
+ PackageDef{"some/other_thing", "latest", 0},
+ },
+ }},
+ f(
+ "some/other_thing latest",
+ "some/thing version",
+ ),
+ },
+
+ {
+ "full file",
+ &File{"https://some.example.com", map[string]PackageSlice{
+ "": {
+ PackageDef{"some/thing", "version", 0},
+ PackageDef{"some/other_thing", "latest", 0},
+ },
+ "path/to root/with/spaces": {
+ PackageDef{"different/package", "some_tag:thingy", 0},
+ },
+ }},
+ f(
+ "$ServiceURL https://some.example.com",
+ "",
+ "some/other_thing latest",
+ "some/thing version",
+ "",
+ "@Root path/to root/with/spaces",
+ "different/package some_tag:thingy",
+ ),
+ },
+}
+
+func TestFileSerialization(t *testing.T) {
+ t.Parallel()
+
+ Convey("File.Serialize", t, func() {
+ for _, tc := range fileSerializationTests {
+ Convey(tc.name, func() {
+ buf := &bytes.Buffer{}
+ _, err := tc.f.Serialize(buf)
+ So(err, ShouldBeNil)
+ So(buf.String(), ShouldEqual, tc.expect)
+ })
+ }
+ })
+}
« no previous file with comments | « cipd/client/cipd/ensure/file.go ('k') | cipd/client/cipd/ensure/good_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698