forked from grpc-ecosystem/go-grpc-middleware
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalidator_test.go
31 lines (24 loc) · 1.08 KB
/
validator_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
// Copyright (c) The go-grpc-middleware Authors.
// Licensed under the Apache License 2.0.
package validator
import (
"context"
"testing"
"github.com/grpc-ecosystem/go-grpc-middleware/v2/testing/testpb"
"github.com/stretchr/testify/assert"
)
func TestValidateWrapper(t *testing.T) {
ctx := context.Background()
assert.NoError(t, validate(ctx, testpb.GoodPing, false, nil))
assert.Error(t, validate(ctx, testpb.BadPing, false, nil))
assert.NoError(t, validate(ctx, testpb.GoodPing, true, nil))
assert.Error(t, validate(ctx, testpb.BadPing, true, nil))
assert.NoError(t, validate(ctx, testpb.GoodPingError, false, nil))
assert.Error(t, validate(ctx, testpb.BadPingError, false, nil))
assert.NoError(t, validate(ctx, testpb.GoodPingError, true, nil))
assert.Error(t, validate(ctx, testpb.BadPingError, true, nil))
assert.NoError(t, validate(ctx, testpb.GoodPingResponse, false, nil))
assert.NoError(t, validate(ctx, testpb.GoodPingResponse, true, nil))
assert.Error(t, validate(ctx, testpb.BadPingResponse, false, nil))
assert.Error(t, validate(ctx, testpb.BadPingResponse, true, nil))
}