(t *testing.T)
| 540 | } |
| 541 | |
| 542 | func TestTestCompatibilityService(t *testing.T) { |
| 543 | t.Parallel() |
| 544 | nc := connect(t) |
| 545 | defer nc.Close() |
| 546 | |
| 547 | type groupConfig struct { |
| 548 | Name string `json:"name"` |
| 549 | QueueGroup string `json:"queue_group"` |
| 550 | } |
| 551 | |
| 552 | type endpointConfig struct { |
| 553 | micro.EndpointConfig |
| 554 | Name string `json:"name"` |
| 555 | Group string `json:"group"` |
| 556 | } |
| 557 | |
| 558 | type config struct { |
| 559 | micro.Config |
| 560 | Groups []groupConfig `json:"groups"` |
| 561 | Endpoints []endpointConfig `json:"endpoints"` |
| 562 | } |
| 563 | |
| 564 | echoHandler := micro.HandlerFunc(func(req micro.Request) { |
| 565 | req.Respond(req.Data()) |
| 566 | }) |
| 567 | |
| 568 | errHandler := micro.HandlerFunc(func(req micro.Request) { |
| 569 | req.Error("500", "handler error", nil) |
| 570 | }) |
| 571 | |
| 572 | // setup subscription on which tester will be sending requests |
| 573 | sub, err := nc.SubscribeSync("tests.service.core.>") |
| 574 | if err != nil { |
| 575 | t.Fatalf("Error subscribing to test subject: %v", err) |
| 576 | } |
| 577 | defer sub.Unsubscribe() |
| 578 | |
| 579 | // 1. Get service and endpoint configs |
| 580 | msg, err := sub.NextMsg(1 * time.Hour) |
| 581 | if err != nil { |
| 582 | t.Fatalf("Error getting message: %v", err) |
| 583 | } |
| 584 | |
| 585 | var cfg serviceStepConfig[*config] |
| 586 | if err := json.Unmarshal(msg.Data, &cfg); err != nil { |
| 587 | t.Fatalf("Error unmarshalling message: %v", err) |
| 588 | } |
| 589 | |
| 590 | var services []micro.Service |
| 591 | svcCfg := cfg.Config |
| 592 | svcCfg.StatsHandler = func(e *micro.Endpoint) any { |
| 593 | return map[string]string{"endpoint": e.Name} |
| 594 | } |
| 595 | svc, err := micro.AddService(nc, svcCfg.Config) |
| 596 | if err != nil { |
| 597 | t.Fatalf("Error adding service: %v", err) |
| 598 | } |
| 599 | groups := make(map[string]micro.Group) |
nothing calls this directly
no test coverage detected