summaryrefslogtreecommitdiff
path: root/data/datasource_stdin_test.go
blob: 6cd34133d1baca81281762b2be60ba41c69bef5d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package data

import (
	"context"
	"strings"
	"testing"

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

func TestReadStdin(t *testing.T) {
	ctx := context.Background()

	ctx = ContextWithStdin(ctx, strings.NewReader("foo"))
	out, err := readStdin(ctx, nil)
	assert.NoError(t, err)
	assert.Equal(t, []byte("foo"), out)

	ctx = ContextWithStdin(ctx, errorReader{})
	_, err = readStdin(ctx, nil)
	assert.Error(t, err)
}