Commit 1764d6a
committed
test(tray): add real unit tests for ServerAdapter with mock client
Replace documentation-style tests with 22 actual unit tests that verify
adapter behavior through mock dependency injection. Changes include:
- Add ClientInterface to enable mock-based testing
- Refactor ServerAdapter to depend on interface instead of concrete Client
- Add MockClient implementation for controlled test scenarios
- Test health data preservation through GetAllServers transformation
- Test isServerHealthy helper with all health level and fallback cases
- Test GetUpstreamStats correctly uses health.level as source of truth
- Test error handling paths for API failures
- Add end-to-end health data flow integration test1 parent cd935b9 commit 1764d6a
2 files changed
Lines changed: 515 additions & 137 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
13 | 23 | | |
14 | 24 | | |
15 | 25 | | |
| |||
23 | 33 | | |
24 | 34 | | |
25 | 35 | | |
26 | | - | |
| 36 | + | |
27 | 37 | | |
28 | 38 | | |
29 | 39 | | |
30 | | - | |
| 40 | + | |
31 | 41 | | |
32 | 42 | | |
33 | 43 | | |
| |||
0 commit comments