1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
13 TestBlock = []byte("The quick brown fox jumps over the lazy dog.")
14 TestHash = "e4d909c290d0fb1ca068ffaddf22cbd0"
16 TestBlock2 = []byte("Pack my box with five dozen liquor jugs.")
17 TestHash2 = "f15ac516f788aec4f30932ffb6395c39"
19 TestBlock3 = []byte("Now is the time for all good men to come to the aid of their country.")
20 TestHash3 = "eed29bbffbc2dbe5e5ee0bb71888e61f"
22 EmptyHash = "d41d8cd98f00b204e9800998ecf8427e"
23 EmptyBlock = []byte("")
26 // A TestableVolume allows test suites to manipulate the state of an
27 // underlying Volume, in order to test behavior in cases that are
28 // impractical to achieve with a sequence of normal Volume operations.
29 type TestableVolume interface {
32 // Returns the strings that a driver uses to record read/write operations.
33 ReadWriteOperationLabelValues() (r, w string)
35 // Specify the value Mtime() should return, until the next
36 // call to Touch, TouchWithDate, or BlockWrite.
37 TouchWithDate(locator string, lastBlockWrite time.Time)
39 // Clean up, delete temporary files.
43 // brbuffer is like bytes.Buffer, but it implements io.WriterAt.
44 // Convenient for testing (volume)BlockRead implementations.
45 type brbuffer struct {
50 func (b *brbuffer) WriteAt(p []byte, offset int64) (int, error) {
53 if short := int(offset) + len(p) - len(b.buf); short > 0 {
54 b.buf = append(b.buf, make([]byte, short)...)
56 return copy(b.buf[offset:], p), nil
59 func (b *brbuffer) Bytes() []byte {
65 func (b *brbuffer) String() string {
71 func (b *brbuffer) Len() int {
77 func (b *brbuffer) Reset() {
83 // a brdiscarder is like io.Discard, but it implements
84 // io.WriterAt. Convenient for testing (volume)BlockRead
85 // implementations when the output is not checked.
86 type brdiscarder struct{}
88 func (brdiscarder) WriteAt(p []byte, offset int64) (int, error) { return len(p), nil }
90 var brdiscard = brdiscarder{}