@@ -20,47 +20,46 @@ import Testing
20
20
21
21
@Suite ( " ClientInterceptorPipelineOperation " )
22
22
struct ClientInterceptorPipelineOperationTests {
23
- @Suite ( " Applies to " )
24
- struct AppliesToTests {
25
- @Test
26
- func all( ) async throws {
27
- let operation = ClientInterceptorPipelineOperation . apply (
28
- . requestCounter( . init( ) ) ,
29
- to: . all
30
- )
23
+ @Test ( " Applies to " , arguments: [
24
+ (
25
+ . all,
26
+ [ . fooBar, . fooBaz, . barFoo, . barBaz] ,
27
+ [ ]
28
+ ) ,
29
+ (
30
+ . services( [ ServiceDescriptor ( package : " pkg " , service: " foo " ) ] ) ,
31
+ [ . fooBar, . fooBaz] ,
32
+ [ . barFoo, . barBaz]
33
+ ) ,
34
+ (
35
+ . methods( [ . barFoo] ) ,
36
+ [ . barFoo] ,
37
+ [ . fooBar, . fooBaz, . barBaz]
38
+ )
39
+ ] as [ ( ClientInterceptorPipelineOperation . Subject , [ MethodDescriptor ] , [ MethodDescriptor ] ) ] )
40
+ func appliesTo(
41
+ operationSubject: ClientInterceptorPipelineOperation . Subject ,
42
+ applicableMethods: [ MethodDescriptor ] ,
43
+ notApplicableMethods: [ MethodDescriptor ]
44
+ ) {
45
+ let operation = ClientInterceptorPipelineOperation . apply (
46
+ . requestCounter( . init( ) ) ,
47
+ to: operationSubject
48
+ )
31
49
32
- #expect( operation. applies ( to: MethodDescriptor ( service: " foo " , method: " bar " ) ) )
33
- #expect( operation. applies ( to: MethodDescriptor ( service: " foo " , method: " baz " ) ) )
34
- #expect( operation. applies ( to: MethodDescriptor ( service: " bar " , method: " foo " ) ) )
35
- #expect( operation. applies ( to: MethodDescriptor ( service: " bar " , method: " baz " ) ) )
50
+ for applicableMethod in applicableMethods {
51
+ #expect( operation. applies ( to: applicableMethod) )
36
52
}
37
53
38
- @Test
39
- func serviceSpecific( ) async throws {
40
- let operation = ClientInterceptorPipelineOperation . apply (
41
- . requestCounter( . init( ) ) ,
42
- to: . services( Set ( [ ServiceDescriptor ( package : " pkg " , service: " foo " ) ] ) )
43
- )
44
-
45
- #expect( operation. applies ( to: MethodDescriptor ( service: " pkg.foo " , method: " bar " ) ) )
46
- #expect( operation. applies ( to: MethodDescriptor ( service: " pkg.foo " , method: " baz " ) ) )
47
-
48
- #expect( !operation. applies ( to: MethodDescriptor ( service: " pkg.bar " , method: " foo " ) ) )
49
- #expect( !operation. applies ( to: MethodDescriptor ( service: " pkg.bar " , method: " baz " ) ) )
50
- }
51
-
52
- @Test
53
- func methodSpecific( ) async throws {
54
- let operation = ClientInterceptorPipelineOperation . apply (
55
- . requestCounter( . init( ) ) ,
56
- to: . methods( Set ( [ MethodDescriptor ( service: " bar " , method: " foo " ) ] ) )
57
- )
58
-
59
- #expect( operation. applies ( to: MethodDescriptor ( service: " bar " , method: " foo " ) ) )
60
-
61
- #expect( !operation. applies ( to: MethodDescriptor ( service: " foo " , method: " bar " ) ) )
62
- #expect( !operation. applies ( to: MethodDescriptor ( service: " foo " , method: " baz " ) ) )
63
- #expect( !operation. applies ( to: MethodDescriptor ( service: " bar " , method: " baz " ) ) )
54
+ for notApplicableMethod in notApplicableMethods {
55
+ #expect( !operation. applies ( to: notApplicableMethod) )
64
56
}
65
57
}
66
58
}
59
+
60
+ extension MethodDescriptor {
61
+ fileprivate static let fooBar = Self ( service: " pkg.foo " , method: " bar " )
62
+ fileprivate static let fooBaz = Self ( service: " pkg.foo " , method: " baz " )
63
+ fileprivate static let barFoo = Self ( service: " pkg.bar " , method: " foo " )
64
+ fileprivate static let barBaz = Self ( service: " pkg.bar " , method: " Baz " )
65
+ }
0 commit comments