Fix Cached flag
This commit is contained in:
+1
-1
@@ -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
|
// 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 {
|
func (fc *fileCache) Ready() bool {
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ var _ = Describe("File Caches", func() {
|
|||||||
// First call is a MISS
|
// First call is a MISS
|
||||||
s, err := fc.Get(context.TODO(), &testArg{"test"})
|
s, err := fc.Get(context.TODO(), &testArg{"test"})
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
|
Expect(s.Cached).To(BeFalse())
|
||||||
Expect(ioutil.ReadAll(s)).To(Equal([]byte("test")))
|
Expect(ioutil.ReadAll(s)).To(Equal([]byte("test")))
|
||||||
|
|
||||||
// Second call is a HIT
|
// Second call is a HIT
|
||||||
@@ -67,6 +68,7 @@ var _ = Describe("File Caches", func() {
|
|||||||
s, err = fc.Get(context.TODO(), &testArg{"test"})
|
s, err = fc.Get(context.TODO(), &testArg{"test"})
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
Expect(ioutil.ReadAll(s)).To(Equal([]byte("test")))
|
Expect(ioutil.ReadAll(s)).To(Equal([]byte("test")))
|
||||||
|
Expect(s.Cached).To(BeTrue())
|
||||||
Expect(called).To(BeFalse())
|
Expect(called).To(BeFalse())
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -79,6 +81,7 @@ var _ = Describe("File Caches", func() {
|
|||||||
// First call is a MISS
|
// First call is a MISS
|
||||||
s, err := fc.Get(context.TODO(), &testArg{"test"})
|
s, err := fc.Get(context.TODO(), &testArg{"test"})
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
|
Expect(s.Cached).To(BeFalse())
|
||||||
Expect(ioutil.ReadAll(s)).To(Equal([]byte("test")))
|
Expect(ioutil.ReadAll(s)).To(Equal([]byte("test")))
|
||||||
|
|
||||||
// Second call is also a MISS
|
// Second call is also a MISS
|
||||||
@@ -86,6 +89,7 @@ var _ = Describe("File Caches", func() {
|
|||||||
s, err = fc.Get(context.TODO(), &testArg{"test"})
|
s, err = fc.Get(context.TODO(), &testArg{"test"})
|
||||||
Expect(err).To(BeNil())
|
Expect(err).To(BeNil())
|
||||||
Expect(ioutil.ReadAll(s)).To(Equal([]byte("test")))
|
Expect(ioutil.ReadAll(s)).To(Equal([]byte("test")))
|
||||||
|
Expect(s.Cached).To(BeFalse())
|
||||||
Expect(called).To(BeTrue())
|
Expect(called).To(BeTrue())
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user