File: validator_test.go

package info (click to toggle)
golang-github-grpc-ecosystem-go-grpc-middleware 2.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,464 kB
  • sloc: makefile: 107; sh: 9
file content (31 lines) | stat: -rw-r--r-- 1,109 bytes parent folder | download | duplicates (3)
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))
}