(t *testing.T)
| 108 | } |
| 109 | |
| 110 | func TestMakeBuilderMapErrors(t *testing.T) { |
| 111 | tests := []struct { |
| 112 | desc string |
| 113 | cfg *rlspb.RouteLookupConfig |
| 114 | wantErrPrefix string |
| 115 | }{ |
| 116 | { |
| 117 | desc: "No GrpcKeyBuilder", |
| 118 | cfg: &rlspb.RouteLookupConfig{}, |
| 119 | wantErrPrefix: "rls: RouteLookupConfig does not contain any GrpcKeyBuilder", |
| 120 | }, |
| 121 | { |
| 122 | desc: "Two GrpcKeyBuilders with same Name", |
| 123 | cfg: &rlspb.RouteLookupConfig{ |
| 124 | GrpcKeybuilders: []*rlspb.GrpcKeyBuilder{goodKeyBuilder1, goodKeyBuilder1}, |
| 125 | }, |
| 126 | wantErrPrefix: "rls: GrpcKeyBuilder in RouteLookupConfig contains repeated Name field", |
| 127 | }, |
| 128 | { |
| 129 | desc: "GrpcKeyBuilder with empty Service field", |
| 130 | cfg: &rlspb.RouteLookupConfig{ |
| 131 | GrpcKeybuilders: []*rlspb.GrpcKeyBuilder{ |
| 132 | { |
| 133 | Names: []*rlspb.GrpcKeyBuilder_Name{ |
| 134 | {Service: "bFoo", Method: "method1"}, |
| 135 | {Service: "bBar"}, |
| 136 | {Method: "method1"}, |
| 137 | }, |
| 138 | Headers: []*rlspb.NameMatcher{{Key: "k1", Names: []string{"n1", "n2"}}}, |
| 139 | }, |
| 140 | goodKeyBuilder1, |
| 141 | }, |
| 142 | }, |
| 143 | wantErrPrefix: "rls: GrpcKeyBuilder in RouteLookupConfig contains a Name field with no Service", |
| 144 | }, |
| 145 | { |
| 146 | desc: "GrpcKeyBuilder with no Name", |
| 147 | cfg: &rlspb.RouteLookupConfig{ |
| 148 | GrpcKeybuilders: []*rlspb.GrpcKeyBuilder{{}, goodKeyBuilder1}, |
| 149 | }, |
| 150 | wantErrPrefix: "rls: GrpcKeyBuilder in RouteLookupConfig does not contain any Name", |
| 151 | }, |
| 152 | { |
| 153 | desc: "GrpcKeyBuilder with requiredMatch field set", |
| 154 | cfg: &rlspb.RouteLookupConfig{ |
| 155 | GrpcKeybuilders: []*rlspb.GrpcKeyBuilder{ |
| 156 | { |
| 157 | Names: []*rlspb.GrpcKeyBuilder_Name{{Service: "bFoo", Method: "method1"}}, |
| 158 | Headers: []*rlspb.NameMatcher{{Key: "k1", Names: []string{"n1", "n2"}, RequiredMatch: true}}, |
| 159 | }, |
| 160 | goodKeyBuilder1, |
| 161 | }, |
| 162 | }, |
| 163 | wantErrPrefix: "rls: GrpcKeyBuilder in RouteLookupConfig has required_match field set", |
| 164 | }, |
| 165 | { |
| 166 | desc: "GrpcKeyBuilder two headers with same key", |
| 167 | cfg: &rlspb.RouteLookupConfig{ |
nothing calls this directly
no test coverage detected