File: bytestream_test.go

package info (click to toggle)
golang-github-go-openapi-runtime 0.0~git20160704.0.11e322e-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 896 kB
  • ctags: 802
  • sloc: sh: 16; makefile: 4
file content (30 lines) | stat: -rw-r--r-- 683 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package runtime

import (
	"bytes"
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestByteStreamConsumer(t *testing.T) {
	cons := ByteStreamConsumer()
	expected := "the data for the stream to be sent over the wire"
	rdr := bytes.NewBufferString(expected)
	var in bytes.Buffer

	if assert.NoError(t, cons.Consume(rdr, &in)) {
		assert.Equal(t, expected, in.String())
	}
}

func TestByteStreamProducer(t *testing.T) {
	cons := ByteStreamProducer()
	var wrtr bytes.Buffer
	expected := "the data for the stream to be sent over the wire"
	out := bytes.NewBufferString(expected)

	if assert.NoError(t, cons.Produce(&wrtr, out)) {
		assert.Equal(t, expected, wrtr.String())
	}
}