File: validateservice.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 (56 lines) | stat: -rw-r--r-- 1,198 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
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
// Copyright (c) The go-grpc-middleware Authors.
// Licensed under the Apache License 2.0.

package testvalidate

import (
	"context"

	testvalidatev1 "github.com/grpc-ecosystem/go-grpc-middleware/v2/testing/testvalidate/v1"
)

type TestValidateService struct {
	testvalidatev1.UnimplementedTestValidateServiceServer
}

func (v *TestValidateService) Send(
	_ context.Context,
	_ *testvalidatev1.SendRequest,
) (*testvalidatev1.SendResponse, error) {
	return &testvalidatev1.SendResponse{}, nil
}

func (v *TestValidateService) SendStream(
	_ *testvalidatev1.SendStreamRequest,
	stream testvalidatev1.TestValidateService_SendStreamServer,
) error {
	for i := 0; i < 10; i++ {
		if err := stream.Send(&testvalidatev1.SendStreamResponse{}); err != nil {
			return err
		}
	}

	return nil
}

// Unary requests for unit testing
var (
	BadUnaryRequest = &testvalidatev1.SendRequest{
		Message: "%any",
	}

	GoodUnaryRequest = &testvalidatev1.SendRequest{
		Message: "good@example.com",
	}
)

// Stream requests for unit testing
var (
	BadStreamRequest = &testvalidatev1.SendStreamRequest{
		Message: "%any",
	}

	GoodStreamRequest = &testvalidatev1.SendStreamRequest{
		Message: "good@example.com",
	}
)