forked from nhatthm/plugin-registry-github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreader_test.go
More file actions
41 lines (27 loc) · 656 Bytes
/
reader_test.go
File metadata and controls
41 lines (27 loc) · 656 Bytes
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
31
32
33
34
35
36
37
38
39
40
41
package github
import (
"errors"
"testing"
"github.com/spf13/afero"
"github.com/stretchr/testify/assert"
)
type data struct{}
func (d data) MarshalYAML() (interface{}, error) {
return nil, errors.New("marshal error")
}
func TestYamlReader(t *testing.T) {
t.Parallel()
r := newYamlReader(42)
data, err := afero.ReadAll(r)
assert.NoError(t, err)
expected := "42\n"
assert.Equal(t, expected, string(data))
}
func TestYamlReader_Error(t *testing.T) {
t.Parallel()
r := newYamlReader(data{})
data, err := afero.ReadAll(r)
expectedError := `marshal error`
assert.Equal(t, []byte{}, data)
assert.EqualError(t, err, expectedError)
}