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
62
63
64
65
66
67
68
69
70
71
72
73
74
|
package middleware
import (
"context"
"testing"
)
type mockIder struct {
Identifier string
}
func (m *mockIder) ID() string { return m.Identifier }
func noError(t *testing.T, err error) {
t.Helper()
if err != nil {
t.Errorf("expect no error, got %v", err)
}
}
func mockInitializeMiddleware(id string) InitializeMiddleware {
return InitializeMiddlewareFunc(id,
func(
ctx context.Context, in InitializeInput, next InitializeHandler,
) (
out InitializeOutput, metadata Metadata, err error,
) {
return next.HandleInitialize(ctx, in)
})
}
func mockSerializeMiddleware(id string) SerializeMiddleware {
return SerializeMiddlewareFunc(id,
func(
ctx context.Context, in SerializeInput, next SerializeHandler,
) (
out SerializeOutput, metadata Metadata, err error,
) {
return next.HandleSerialize(ctx, in)
})
}
func mockBuildMiddleware(id string) BuildMiddleware {
return BuildMiddlewareFunc(id,
func(
ctx context.Context, in BuildInput, next BuildHandler,
) (
out BuildOutput, metadata Metadata, err error,
) {
return next.HandleBuild(ctx, in)
})
}
func mockFinalizeMiddleware(id string) FinalizeMiddleware {
return FinalizeMiddlewareFunc(id,
func(
ctx context.Context, in FinalizeInput, next FinalizeHandler,
) (
out FinalizeOutput, metadata Metadata, err error,
) {
return next.HandleFinalize(ctx, in)
})
}
func mockDeserializeMiddleware(id string) DeserializeMiddleware {
return DeserializeMiddlewareFunc(id,
func(
ctx context.Context, in DeserializeInput, next DeserializeHandler,
) (
out DeserializeOutput, metadata Metadata, err error,
) {
return next.HandleDeserialize(ctx, in)
})
}
|