Skip to content

Commit 5993178

Browse files
authored
chore: add test for the change #5289 to ensure it doesn't break silently in the future (#5297)
1 parent 79b84e2 commit 5993178

1 file changed

Lines changed: 38 additions & 1 deletion

File tree

spring-boot-admin-server-ui/src/main/frontend/services/instance.spec.ts

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { AxiosError } from 'axios';
2-
import { describe, expect, test, vi } from 'vitest';
2+
import { http } from 'msw';
3+
import { firstValueFrom } from 'rxjs';
4+
import { describe, expect, it, test, vi } from 'vitest';
35

6+
import { server } from '@/mocks/server';
47
import Instance from '@/services/instance';
58

69
const { useSbaConfig } = vi.hoisted(() => ({
@@ -181,4 +184,38 @@ describe('Instance', () => {
181184
);
182185
});
183186
});
187+
188+
describe('streamLogFile', () => {
189+
const instance = new Instance({
190+
id: 'test-id',
191+
registration: {
192+
name: 'test',
193+
healthUrl: '',
194+
source: '',
195+
},
196+
});
197+
198+
it('should handle single JSON log line correctly', async () => {
199+
const payload = '{"foo":"bar"}';
200+
server.use(
201+
http.get(
202+
'/instances/:instanceId/actuator/logfile',
203+
() =>
204+
// As per Spring Boot definition: https://docs.spring.io/spring-boot/api/rest/actuator/logfile.html
205+
new Response(payload, {
206+
headers: {
207+
'Accept-Ranges': 'bytes',
208+
'Content-Type': 'text/plain;charset=UTF-8',
209+
'Content-Length': payload.length.toString(),
210+
},
211+
}),
212+
),
213+
);
214+
215+
const source = instance.streamLogfile(0);
216+
const { addendum } = await firstValueFrom(source);
217+
218+
expect(addendum).toEqual(payload);
219+
});
220+
});
184221
});

0 commit comments

Comments
 (0)