MCPcopy
hub / github.com/grpc/grpc-go / TestMethodInConfiguration

Method TestMethodInConfiguration

gcp/observability/logging_test.go:1242–1347  ·  view source on GitHub ↗

TestMethodInConfiguration tests different method names with an expectation on whether they should error or not.

(t *testing.T)

Source from the content-addressed store, hash-verified

1240// TestMethodInConfiguration tests different method names with an expectation on
1241// whether they should error or not.
1242func (s) TestMethodInConfiguration(t *testing.T) {
1243
1244 // To skip creating a stackdriver exporter.
1245 fle := &fakeLoggingExporter{
1246 t: t,
1247 }
1248
1249 defer func(ne func(ctx context.Context, config *config) (loggingExporter, error)) {
1250 newLoggingExporter = ne
1251 }(newLoggingExporter)
1252
1253 newLoggingExporter = func(_ context.Context, _ *config) (loggingExporter, error) {
1254 return fle, nil
1255 }
1256
1257 tests := []struct {
1258 name string
1259 config *config
1260 wantErr string
1261 }{
1262 {
1263 name: "leading-slash",
1264 config: &config{
1265 ProjectID: "fake",
1266 CloudLogging: &cloudLogging{
1267 ClientRPCEvents: []clientRPCEvents{
1268 {
1269 Methods: []string{"/service/method"},
1270 },
1271 },
1272 },
1273 },
1274 wantErr: "cannot have a leading slash",
1275 },
1276 {
1277 name: "wildcard service/method",
1278 config: &config{
1279 ProjectID: "fake",
1280 CloudLogging: &cloudLogging{
1281 ClientRPCEvents: []clientRPCEvents{
1282 {
1283 Methods: []string{"*/method"},
1284 },
1285 },
1286 },
1287 },
1288 wantErr: "cannot have service wildcard *",
1289 },
1290 {
1291 name: "/ in service name",
1292 config: &config{
1293 ProjectID: "fake",
1294 CloudLogging: &cloudLogging{
1295 ClientRPCEvents: []clientRPCEvents{
1296 {
1297 Methods: []string{"ser/vice/method"},
1298 },
1299 },

Callers

nothing calls this directly

Calls 3

ErrorMethod · 0.65
FatalfMethod · 0.65

Tested by

no test coverage detected