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

Unified Diff: cipd/client/cipd/local/reader_test.go

Issue 2872193003: [cipd] delete bad cache files when failing do deploy them. (Closed)
Patch Set: fix things Created 3 years, 7 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/local/reader.go ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cipd/client/cipd/local/reader_test.go
diff --git a/cipd/client/cipd/local/reader_test.go b/cipd/client/cipd/local/reader_test.go
index d73688c81e2528807bc19d1fc2ea22d82efb16d0..418ae844d5197d61f1b841607177534422fe6476 100644
--- a/cipd/client/cipd/local/reader_test.go
+++ b/cipd/client/cipd/local/reader_test.go
@@ -49,6 +49,16 @@ func shouldBeSameJSONDict(actual interface{}, expected ...interface{}) string {
return ShouldEqual(actualNorm, expectedNorm)
}
+type bytesInstanceFile struct {
+ *bytes.Reader
+}
+
+func (bytesInstanceFile) Close(context.Context, bool) error { return nil }
+
+func bytesFile(data []byte) InstanceFile {
+ return bytesInstanceFile{bytes.NewReader(data)}
+}
+
func TestPackageReading(t *testing.T) {
ctx := context.Background()
@@ -63,7 +73,7 @@ func TestPackageReading(t *testing.T) {
So(err, ShouldBeNil)
// Open it.
- inst, err := OpenInstance(ctx, bytes.NewReader(out.Bytes()), "", VerifyHash)
+ inst, err := OpenInstance(ctx, bytesFile(out.Bytes()), "", VerifyHash)
So(inst, ShouldNotBeNil)
So(err, ShouldBeNil)
So(inst.Pin(), ShouldResemble, Pin{"testing", "23f2c4900785ac8faa2f38e473925b840e574ccc"})
@@ -99,7 +109,7 @@ func TestPackageReading(t *testing.T) {
So(err, ShouldBeNil)
// Attempt to open it, providing correct instance ID, should work.
- source := bytes.NewReader(out.Bytes())
+ source := bytesFile(out.Bytes())
inst, err := OpenInstance(ctx, source, "23f2c4900785ac8faa2f38e473925b840e574ccc", VerifyHash)
So(err, ShouldBeNil)
So(inst, ShouldNotBeNil)
@@ -168,7 +178,7 @@ func TestPackageReading(t *testing.T) {
So(err, ShouldBeNil)
// Extract files.
- inst, err := OpenInstance(ctx, bytes.NewReader(out.Bytes()), "", VerifyHash)
+ inst, err := OpenInstance(ctx, bytesFile(out.Bytes()), "", VerifyHash)
So(err, ShouldBeNil)
dest := &testDestination{}
err = ExtractInstance(ctx, inst, dest, func(f File) bool {
« no previous file with comments | « cipd/client/cipd/local/reader.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698