-
Notifications
You must be signed in to change notification settings - Fork 2
/
server_internal_test.go
61 lines (40 loc) · 1.77 KB
/
server_internal_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
52
53
54
55
56
57
58
59
60
61
package grpcsteps
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
)
func TestExternalServiceManager_ReceiveOneRequestWithPayloadFromFile_ReadFileError(t *testing.T) {
t.Parallel()
_, err := NewExternalServiceManager().
receiveOneRequestWithPayloadFromFile(context.Background(), "item-service", "/grpctest.ItemService/GetItem", "not_found")
expected := `open not_found: no such file or directory`
assert.EqualError(t, err, expected)
}
func TestExternalServiceManager_ReceiveRepeatedRequestsWithPayloadFromFile_ReadFileError(t *testing.T) {
t.Parallel()
_, err := NewExternalServiceManager().
receiveRepeatedRequestsWithPayloadFromFile(context.Background(), "item-service", 10, "/grpctest.ItemService/GetItem", "not_found")
expected := `open not_found: no such file or directory`
assert.EqualError(t, err, expected)
}
func TestExternalServiceManager_ReceiveManyRequestsWithPayloadFromFile_ReadFileError(t *testing.T) {
t.Parallel()
_, err := NewExternalServiceManager().
receiveManyRequestsWithPayloadFromFile(context.Background(), "item-service", "/grpctest.ItemService/GetItem", "not_found")
expected := `open not_found: no such file or directory`
assert.EqualError(t, err, expected)
}
func TestExternalServiceManager_respondWithPayloadFromFile_ReadFileError(t *testing.T) {
t.Parallel()
err := NewExternalServiceManager().
respondWithPayloadFromFile(context.Background(), "not_found")
expected := `open not_found: no such file or directory`
assert.EqualError(t, err, expected)
}
func TestExternalServiceManager_RespondWithError_InvalidCode(t *testing.T) {
t.Parallel()
err := NewExternalServiceManager().respondWithError(context.Background(), `not a code`, ``)
expected := `invalid code: "\"NOT A CODE\""`
assert.EqualError(t, err, expected)
}