From f8f16d676dbc6ac530518ea74113afdd55d16fe1 Mon Sep 17 00:00:00 2001 From: Deluan Date: Fri, 24 Jul 2020 18:46:08 -0400 Subject: [PATCH] Fix Cached flag --- core/file_caches.go | 2 +- core/file_caches_test.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/core/file_caches.go b/core/file_caches.go index c0be7a709..ce7424880 100644 --- a/core/file_caches.go +++ b/core/file_caches.go @@ -105,7 +105,7 @@ func (fc *fileCache) Get(ctx context.Context, arg fmt.Stringer) (*CachedStream, } // All other cases, just return a Reader, without Seek capabilities - return &CachedStream{Reader: r, Cached: true}, nil + return &CachedStream{Reader: r, Cached: cached}, nil } func (fc *fileCache) Ready() bool { diff --git a/core/file_caches_test.go b/core/file_caches_test.go index 4d3f19ae8..deca91776 100644 --- a/core/file_caches_test.go +++ b/core/file_caches_test.go @@ -60,6 +60,7 @@ var _ = Describe("File Caches", func() { // First call is a MISS s, err := fc.Get(context.TODO(), &testArg{"test"}) Expect(err).To(BeNil()) + Expect(s.Cached).To(BeFalse()) Expect(ioutil.ReadAll(s)).To(Equal([]byte("test"))) // Second call is a HIT @@ -67,6 +68,7 @@ var _ = Describe("File Caches", func() { s, err = fc.Get(context.TODO(), &testArg{"test"}) Expect(err).To(BeNil()) Expect(ioutil.ReadAll(s)).To(Equal([]byte("test"))) + Expect(s.Cached).To(BeTrue()) Expect(called).To(BeFalse()) }) @@ -79,6 +81,7 @@ var _ = Describe("File Caches", func() { // First call is a MISS s, err := fc.Get(context.TODO(), &testArg{"test"}) Expect(err).To(BeNil()) + Expect(s.Cached).To(BeFalse()) Expect(ioutil.ReadAll(s)).To(Equal([]byte("test"))) // Second call is also a MISS @@ -86,6 +89,7 @@ var _ = Describe("File Caches", func() { s, err = fc.Get(context.TODO(), &testArg{"test"}) Expect(err).To(BeNil()) Expect(ioutil.ReadAll(s)).To(Equal([]byte("test"))) + Expect(s.Cached).To(BeFalse()) Expect(called).To(BeTrue()) }) })