mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
4f0d95fa6e
Signed-off-by: Daniel Nephin <dnephin@docker.com>
27 lines
697 B
Go
27 lines
697 B
Go
package testutil // import "github.com/docker/docker/internal/testutil"
|
|
|
|
import (
|
|
"io"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
// ErrorContains checks that the error is not nil, and contains the expected
|
|
// substring.
|
|
func ErrorContains(t require.TestingT, err error, expectedError string, msgAndArgs ...interface{}) {
|
|
require.Error(t, err, msgAndArgs...)
|
|
assert.Contains(t, err.Error(), expectedError, msgAndArgs...)
|
|
}
|
|
|
|
// DevZero acts like /dev/zero but in an OS-independent fashion.
|
|
var DevZero io.Reader = devZero{}
|
|
|
|
type devZero struct{}
|
|
|
|
func (d devZero) Read(p []byte) (n int, err error) {
|
|
for i := range p {
|
|
p[i] = 0
|
|
}
|
|
return len(p), nil
|
|
}
|