MCPcopy Create free account
hub / github.com/containers/image / TestUploadReader

Function TestUploadReader

internal/uploadreader/upload_reader_test.go:13–34  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func TestUploadReader(t *testing.T) {
14 // This is a smoke test in a single goroutine, without really testing the locking.
15
16 data := bytes.Repeat([]byte{0x01}, 65535)
17 // No termination
18 ur := NewUploadReader(bytes.NewReader(data))
19 read, err := io.ReadAll(ur)
20 require.NoError(t, err)
21 assert.Equal(t, data, read)
22
23 // Terminated
24 ur = NewUploadReader(bytes.NewReader(data))
25 readLen := len(data) / 2
26 read, err = io.ReadAll(io.LimitReader(ur, int64(readLen)))
27 require.NoError(t, err)
28 assert.Equal(t, data[:readLen], read)
29 terminationErr := errors.New("Terminated")
30 ur.Terminate(terminationErr)
31 read, err = io.ReadAll(ur)
32 assert.Equal(t, terminationErr, err)
33 assert.Len(t, read, 0)
34}

Callers

nothing calls this directly

Calls 2

TerminateMethod · 0.95
NewUploadReaderFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…