Skip to content

Commit

Permalink
move tests outside of constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewazores committed Jan 28, 2025
1 parent 01f39c7 commit ae6c3ef
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/app/Shared/Services/Api.service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,9 @@ export class ApiService {
private readonly ctx: CryostatContext,
private readonly target: TargetService,
private readonly notifications: NotificationService,
) {
this.doGet('recordings')
.pipe(
catchError(() => {
this.archiveEnabled.next(false);
return EMPTY;
}),
)
.subscribe();
) {}

testHealth() {
const getDatasourceURL: Observable<GrafanaDashboardUrlGetResponse> = this.ctx
.url('/api/v4/grafana_datasource_url')
.pipe(
Expand Down Expand Up @@ -381,6 +374,17 @@ export class ApiService {
);
}

testArchiveAvailability() {
this.doGet('recordings')
.pipe(
catchError(() => {
this.archiveEnabled.next(false);
return EMPTY;
}),
)
.subscribe();
}

isArchiveEnabled(): Observable<boolean> {
return this.archiveEnabled.asObservable();
}
Expand Down
3 changes: 3 additions & 0 deletions src/app/Shared/Services/Services.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ const notificationChannel = new NotificationChannel(NotificationsInstance, login
const reports = new ReportService(NotificationsInstance, notificationChannel);
const targets = new TargetsService(api, NotificationsInstance, notificationChannel);

api.testHealth();
api.testArchiveAvailability();

const defaultServices: Services = {
target,
targets,
Expand Down

0 comments on commit ae6c3ef

Please sign in to comment.