forked from cucumber/gherkin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
messages_test.go
51 lines (41 loc) · 911 Bytes
/
messages_test.go
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
42
43
44
45
46
47
48
49
50
51
package gherkin
import (
"bytes"
"encoding/json"
"github.com/cucumber/messages/go/v22"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
)
func TestMessagesWithStdin(t *testing.T) {
stdin := &bytes.Buffer{}
encoder := json.NewEncoder(stdin)
gherkin := `Feature: Minimal
Scenario: a
Given a
Scenario: b
Given b
`
envelope := &messages.Envelope{
Source: &messages.Source{
Uri: "features/test.feature",
Data: gherkin,
MediaType: "text/x.cucumber.gherkin+plain",
},
}
require.NoError(t, encoder.Encode(envelope))
require.NoError(t, encoder.Encode(envelope))
decoder := json.NewDecoder(stdin)
writtenMessages, err := Messages(
nil,
decoder,
"en",
true,
true,
true,
nil,
(&messages.Incrementing{}).NewId,
)
require.NoError(t, err)
assert.Equal(t, 8, len(writtenMessages), "Wrong number of messages")
}