mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Update the InputStream tests
This commit is contained in:
parent
31d1607a51
commit
ab25c40ceb
@ -412,7 +412,7 @@ func (obj *SimpleStream) DeepCopyObject() runtime.Object {
|
|||||||
panic("SimpleStream does not support DeepCopy")
|
panic("SimpleStream does not support DeepCopy")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SimpleStream) InputStream(version, accept string) (io.ReadCloser, bool, string, error) {
|
func (s *SimpleStream) InputStream(_ context.Context, version, accept string) (io.ReadCloser, bool, string, error) {
|
||||||
s.version = version
|
s.version = version
|
||||||
s.accept = accept
|
s.accept = accept
|
||||||
return s, false, s.contentType, s.err
|
return s, false, s.contentType, s.err
|
||||||
|
@ -19,6 +19,7 @@ package rest
|
|||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -45,7 +46,7 @@ func TestInputStreamReader(t *testing.T) {
|
|||||||
streamer := &LocationStreamer{
|
streamer := &LocationStreamer{
|
||||||
Location: u,
|
Location: u,
|
||||||
}
|
}
|
||||||
readCloser, _, _, err := streamer.InputStream("", "")
|
readCloser, _, _, err := streamer.InputStream(context.Background(), "", "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Unexpected error when getting stream: %v", err)
|
t.Errorf("Unexpected error when getting stream: %v", err)
|
||||||
return
|
return
|
||||||
@ -61,7 +62,7 @@ func TestInputStreamNullLocation(t *testing.T) {
|
|||||||
streamer := &LocationStreamer{
|
streamer := &LocationStreamer{
|
||||||
Location: nil,
|
Location: nil,
|
||||||
}
|
}
|
||||||
readCloser, _, _, err := streamer.InputStream("", "")
|
readCloser, _, _, err := streamer.InputStream(context.Background(), "", "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Unexpected error when getting stream with null location: %v", err)
|
t.Errorf("Unexpected error when getting stream with null location: %v", err)
|
||||||
}
|
}
|
||||||
@ -91,7 +92,7 @@ func TestInputStreamContentType(t *testing.T) {
|
|||||||
Location: location,
|
Location: location,
|
||||||
Transport: fakeTransport("application/json", "hello world"),
|
Transport: fakeTransport("application/json", "hello world"),
|
||||||
}
|
}
|
||||||
readCloser, _, contentType, err := streamer.InputStream("", "")
|
readCloser, _, contentType, err := streamer.InputStream(context.Background(), "", "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Unexpected error when getting stream: %v", err)
|
t.Errorf("Unexpected error when getting stream: %v", err)
|
||||||
return
|
return
|
||||||
@ -109,7 +110,7 @@ func TestInputStreamTransport(t *testing.T) {
|
|||||||
Location: location,
|
Location: location,
|
||||||
Transport: fakeTransport("text/plain", message),
|
Transport: fakeTransport("text/plain", message),
|
||||||
}
|
}
|
||||||
readCloser, _, _, err := streamer.InputStream("", "")
|
readCloser, _, _, err := streamer.InputStream(context.Background(), "", "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Unexpected error when getting stream: %v", err)
|
t.Errorf("Unexpected error when getting stream: %v", err)
|
||||||
return
|
return
|
||||||
@ -136,7 +137,7 @@ func TestInputStreamInternalServerErrorTransport(t *testing.T) {
|
|||||||
}
|
}
|
||||||
expectedError := errors.NewInternalError(fmt.Errorf("%s", message))
|
expectedError := errors.NewInternalError(fmt.Errorf("%s", message))
|
||||||
|
|
||||||
_, _, _, err := streamer.InputStream("", "")
|
_, _, _, err := streamer.InputStream(context.Background(), "", "")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Errorf("unexpected non-error")
|
t.Errorf("unexpected non-error")
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user