]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/shared/api/cephfs.service.spec.ts
import 15.2.0 Octopus source
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / shared / api / cephfs.service.spec.ts
1 import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
2 import { TestBed } from '@angular/core/testing';
3
4 import { configureTestBed } from '../../../testing/unit-test-helper';
5 import { CephfsService } from './cephfs.service';
6
7 describe('CephfsService', () => {
8 let service: CephfsService;
9 let httpTesting: HttpTestingController;
10
11 configureTestBed({
12 imports: [HttpClientTestingModule],
13 providers: [CephfsService]
14 });
15
16 beforeEach(() => {
17 service = TestBed.get(CephfsService);
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 list', () => {
30 service.list().subscribe();
31 const req = httpTesting.expectOne('api/cephfs');
32 expect(req.request.method).toBe('GET');
33 });
34
35 it('should call getCephfs', () => {
36 service.getCephfs(1).subscribe();
37 const req = httpTesting.expectOne('api/cephfs/1');
38 expect(req.request.method).toBe('GET');
39 });
40
41 it('should call getClients', () => {
42 service.getClients(1).subscribe();
43 const req = httpTesting.expectOne('api/cephfs/1/clients');
44 expect(req.request.method).toBe('GET');
45 });
46
47 it('should call getTabs', () => {
48 service.getTabs(2).subscribe();
49 const req = httpTesting.expectOne('ui-api/cephfs/2/tabs');
50 expect(req.request.method).toBe('GET');
51 });
52
53 it('should call getMdsCounters', () => {
54 service.getMdsCounters('1').subscribe();
55 const req = httpTesting.expectOne('api/cephfs/1/mds_counters');
56 expect(req.request.method).toBe('GET');
57 });
58
59 it('should call lsDir', () => {
60 service.lsDir(1).subscribe();
61 const req = httpTesting.expectOne('ui-api/cephfs/1/ls_dir?depth=2');
62 expect(req.request.method).toBe('GET');
63 service.lsDir(2, '/some/path').subscribe();
64 httpTesting.expectOne('ui-api/cephfs/2/ls_dir?depth=2&path=%252Fsome%252Fpath');
65 });
66
67 it('should call mkSnapshot', () => {
68 service.mkSnapshot(3, '/some/path').subscribe();
69 const req = httpTesting.expectOne('api/cephfs/3/mk_snapshot?path=%252Fsome%252Fpath');
70 expect(req.request.method).toBe('POST');
71
72 service.mkSnapshot(4, '/some/other/path', 'snap').subscribe();
73 httpTesting.expectOne('api/cephfs/4/mk_snapshot?path=%252Fsome%252Fother%252Fpath&name=snap');
74 });
75
76 it('should call rmSnapshot', () => {
77 service.rmSnapshot(1, '/some/path', 'snap').subscribe();
78 const req = httpTesting.expectOne('api/cephfs/1/rm_snapshot?path=%252Fsome%252Fpath&name=snap');
79 expect(req.request.method).toBe('POST');
80 });
81
82 it('should call updateQuota', () => {
83 service.updateQuota(1, '/some/path', { max_bytes: 1024 }).subscribe();
84 let req = httpTesting.expectOne('api/cephfs/1/set_quotas?path=%252Fsome%252Fpath');
85 expect(req.request.method).toBe('POST');
86 expect(req.request.body).toEqual({ max_bytes: 1024 });
87
88 service.updateQuota(1, '/some/path', { max_files: 10 }).subscribe();
89 req = httpTesting.expectOne('api/cephfs/1/set_quotas?path=%252Fsome%252Fpath');
90 expect(req.request.method).toBe('POST');
91 expect(req.request.body).toEqual({ max_files: 10 });
92
93 service.updateQuota(1, '/some/path', { max_bytes: 1024, max_files: 10 }).subscribe();
94 req = httpTesting.expectOne('api/cephfs/1/set_quotas?path=%252Fsome%252Fpath');
95 expect(req.request.method).toBe('POST');
96 expect(req.request.body).toEqual({ max_bytes: 1024, max_files: 10 });
97 });
98 });