Ejemplo n.º 1
0
// Create a mutable content object whose initial contents are given by the
// supplied read proxy.
func NewContent(
	initialContent lease.ReadProxy,
	clock timeutil.Clock) (mc Content) {
	mc = &mutableContent{
		clock:          clock,
		initialContent: initialContent,
		dirtyThreshold: initialContent.Size(),
	}

	return
}
Ejemplo n.º 2
0
func runReadAtTestCases(
	rp lease.ReadProxy,
	cases []readAtTestCase) {
	for i, tc := range cases {
		desc := fmt.Sprintf("Test case %d: [%d, %d)", i, tc.start, tc.limit)

		AssertLe(tc.start, tc.limit)
		buf := make([]byte, tc.limit-tc.start)

		n, err := rp.ReadAt(context.Background(), buf, tc.start)
		AssertEq(tc.expectedContents, string(buf[:n]), "%s", desc)

		if tc.errMatcher == nil {
			AssertEq(nil, err, "%s", desc)
		} else {
			ExpectThat(err, tc.errMatcher, desc)
		}
	}
}