Update go dependencies (#2234)
This commit is contained in:
parent
6e099c5f57
commit
93c72ef646
1236 changed files with 37226 additions and 49844 deletions
56
vendor/k8s.io/apimachinery/pkg/util/yaml/decoder_test.go
generated
vendored
56
vendor/k8s.io/apimachinery/pkg/util/yaml/decoder_test.go
generated
vendored
|
|
@ -22,12 +22,68 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"math/rand"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestYAMLDecoderReadBytesLength(t *testing.T) {
|
||||
d := `---
|
||||
stuff: 1
|
||||
test-foo: 1
|
||||
`
|
||||
testCases := []struct {
|
||||
bufLen int
|
||||
expectLen int
|
||||
expectErr error
|
||||
}{
|
||||
{len(d), len(d), nil},
|
||||
{len(d) + 10, len(d), nil},
|
||||
{len(d) - 10, len(d) - 10, io.ErrShortBuffer},
|
||||
}
|
||||
|
||||
for i, testCase := range testCases {
|
||||
r := NewDocumentDecoder(ioutil.NopCloser(bytes.NewReader([]byte(d))))
|
||||
b := make([]byte, testCase.bufLen)
|
||||
n, err := r.Read(b)
|
||||
if err != testCase.expectErr || n != testCase.expectLen {
|
||||
t.Fatalf("%d: unexpected body: %d / %v", i, n, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestYAMLDecoderCallsAfterErrShortBufferRestOfFrame(t *testing.T) {
|
||||
d := `---
|
||||
stuff: 1
|
||||
test-foo: 1`
|
||||
r := NewDocumentDecoder(ioutil.NopCloser(bytes.NewReader([]byte(d))))
|
||||
b := make([]byte, 12)
|
||||
n, err := r.Read(b)
|
||||
if err != io.ErrShortBuffer || n != 12 {
|
||||
t.Fatalf("expected ErrShortBuffer: %d / %v", n, err)
|
||||
}
|
||||
expected := "---\nstuff: 1"
|
||||
if string(b) != expected {
|
||||
t.Fatalf("expected bytes read to be: %s got: %s", expected, string(b))
|
||||
}
|
||||
b = make([]byte, 13)
|
||||
n, err = r.Read(b)
|
||||
if err != nil || n != 13 {
|
||||
t.Fatalf("expected nil: %d / %v", n, err)
|
||||
}
|
||||
expected = "\n\ttest-foo: 1"
|
||||
if string(b) != expected {
|
||||
t.Fatalf("expected bytes read to be: '%s' got: '%s'", expected, string(b))
|
||||
}
|
||||
b = make([]byte, 15)
|
||||
n, err = r.Read(b)
|
||||
if err != io.EOF || n != 0 {
|
||||
t.Fatalf("expected EOF: %d / %v", n, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSplitYAMLDocument(t *testing.T) {
|
||||
testCases := []struct {
|
||||
input string
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue