]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/shared/api/osd.service.spec.ts
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / shared / api / osd.service.spec.ts
1 import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
2 import { TestBed } from '@angular/core/testing';
3
4 import { configureTestBed, i18nProviders } from '../../../testing/unit-test-helper';
5 import { OsdService } from './osd.service';
6
7 describe('OsdService', () => {
8 let service: OsdService;
9 let httpTesting: HttpTestingController;
10
11 configureTestBed({
12 providers: [OsdService, i18nProviders],
13 imports: [HttpClientTestingModule]
14 });
15
16 beforeEach(() => {
17 service = TestBed.get(OsdService);
18 httpTesting = TestBed.get(HttpTestingController);
19 });
20
21 afterEach(() => {
22 httpTesting.verify();
23 });
24
25 it('should be created', () => {
26 expect(service).toBeTruthy();
27 });
28
29 it('should call getList', () => {
30 service.getList().subscribe();
31 const req = httpTesting.expectOne('api/osd');
32 expect(req.request.method).toBe('GET');
33 });
34
35 it('should call getDetails', () => {
36 service.getDetails(1).subscribe();
37 const req = httpTesting.expectOne('api/osd/1');
38 expect(req.request.method).toBe('GET');
39 });
40
41 it('should call scrub, with deep=true', () => {
42 service.scrub('foo', true).subscribe();
43 const req = httpTesting.expectOne('api/osd/foo/scrub?deep=true');
44 expect(req.request.method).toBe('POST');
45 });
46
47 it('should call scrub, with deep=false', () => {
48 service.scrub('foo', false).subscribe();
49 const req = httpTesting.expectOne('api/osd/foo/scrub?deep=false');
50 expect(req.request.method).toBe('POST');
51 });
52
53 it('should call getFlags', () => {
54 service.getFlags().subscribe();
55 const req = httpTesting.expectOne('api/osd/flags');
56 expect(req.request.method).toBe('GET');
57 });
58
59 it('should call updateFlags', () => {
60 service.updateFlags(['foo']).subscribe();
61 const req = httpTesting.expectOne('api/osd/flags');
62 expect(req.request.method).toBe('PUT');
63 expect(req.request.body).toEqual({ flags: ['foo'] });
64 });
65
66 it('should mark the OSD out', () => {
67 service.markOut(1).subscribe();
68 const req = httpTesting.expectOne('api/osd/1/mark_out');
69 expect(req.request.method).toBe('POST');
70 });
71
72 it('should mark the OSD in', () => {
73 service.markIn(1).subscribe();
74 const req = httpTesting.expectOne('api/osd/1/mark_in');
75 expect(req.request.method).toBe('POST');
76 });
77
78 it('should mark the OSD down', () => {
79 service.markDown(1).subscribe();
80 const req = httpTesting.expectOne('api/osd/1/mark_down');
81 expect(req.request.method).toBe('POST');
82 });
83
84 it('should reweight an OSD', () => {
85 service.reweight(1, 0.5).subscribe();
86 const req = httpTesting.expectOne('api/osd/1/reweight');
87 expect(req.request.method).toBe('POST');
88 expect(req.request.body).toEqual({ weight: 0.5 });
89 });
90
91 it('should mark an OSD lost', () => {
92 service.markLost(1).subscribe();
93 const req = httpTesting.expectOne('api/osd/1/mark_lost');
94 expect(req.request.method).toBe('POST');
95 });
96
97 it('should purge an OSD', () => {
98 service.purge(1).subscribe();
99 const req = httpTesting.expectOne('api/osd/1/purge');
100 expect(req.request.method).toBe('POST');
101 });
102
103 it('should destroy an OSD', () => {
104 service.destroy(1).subscribe();
105 const req = httpTesting.expectOne('api/osd/1/destroy');
106 expect(req.request.method).toBe('POST');
107 });
108
109 it('should return if it is safe to destroy an OSD', () => {
110 service.safeToDestroy(1).subscribe();
111 const req = httpTesting.expectOne('api/osd/1/safe_to_destroy');
112 expect(req.request.method).toBe('GET');
113 });
114 });