also looking at this
fix(operations): the inventory read a location Hetzner no longer sends
#193
2 files
+69
-2
| @@ -63,6 +63,26 @@ describe('shaping a provider server', () => { | ||
| 63 | 63 | .toMatchObject({ ipv4: '1.2.3.4', type: 'medium', location: 'nbg1' }) |
| 64 | 64 | }) |
| 65 | 65 | |
| 66 | it('reads the location off the shape the API actually returns today', () => { | |
| 67 | // The regression this guards. Hetzner retired `datacenter` and nests the | |
| 68 | // place under `location`, which this read as a bare string - so every live | |
| 69 | // box reported no location at all. `resize.ts` and `role-swap.ts` already | |
| 70 | // carry the same fallback; this is the third reader to need it. | |
| 71 | expect(toInventoryServer({ | |
| 72 | id: 3, | |
| 73 | name: 'stacks-production-app', | |
| 74 | status: 'running', | |
| 75 | datacenter: null, | |
| 76 | location: { id: 1, name: 'fsn1', city: 'Falkenstein' }, | |
| 77 | labels: {}, | |
| 78 | })).toMatchObject({ location: 'fsn1' }) | |
| 79 | }) | |
| 80 | ||
| 81 | it('still prefers the legacy datacenter when a recorded fixture carries one', () => { | |
| 82 | expect(toInventoryServer({ id: 4, name: 'box', status: 'running', datacenter: { name: 'fsn1-dc14' }, labels: {} })) | |
| 83 | .toMatchObject({ location: 'fsn1-dc14' }) | |
| 84 | }) | |
| 85 | ||
| 66 | 86 | it('keeps an unlabelled box rather than dropping it', () => { |
| 67 | 87 | // A box provisioned by hand, or by a ts-cloud old enough not to label, is |
| 68 | 88 | // exactly the kind a consolidation needs to see. |