文件操作 - buildCategories.test.ts
返回文件管理
返回主菜单
删除本文件
文件: /usr/share/grafana/public/app/features/datasources/state/buildCategories.test.ts
编辑文件内容
import { buildCategories } from './buildCategories'; import { getMockPlugin } from '../../plugins/__mocks__/pluginMocks'; import { DataSourcePluginMeta } from '@grafana/data'; const plugins: DataSourcePluginMeta[] = [ { ...getMockPlugin({ id: 'graphite' }), category: 'tsdb', }, { ...getMockPlugin({ id: 'prometheus' }), category: 'tsdb', }, { ...getMockPlugin({ id: 'elasticsearch' }), category: 'logging', }, { ...getMockPlugin({ id: 'loki' }), category: 'logging', }, { ...getMockPlugin({ id: 'azure' }), category: 'cloud', }, ]; describe('buildCategories', () => { const categories = buildCategories(plugins); it('should group plugins into categories', () => { expect(categories.length).toBe(7); expect(categories[0].title).toBe('Time series databases'); expect(categories[0].plugins.length).toBe(2); expect(categories[1].title).toBe('Logging & document databases'); }); it('should sort plugins according to hard coded sorting rules', () => { expect(categories[1].plugins[0].id).toBe('loki'); }); it('should add phantom plugin for Grafana cloud', () => { expect(categories[4].title).toBe('Cloud'); expect(categories[4].plugins.length).toBe(2); expect(categories[4].plugins[1].id).toBe('gcloud'); }); it('should set module to phantom on phantom plugins', () => { expect(categories[5].plugins[0].module).toBe('phantom'); }); it('should add enterprise phantom plugins', () => { expect(categories[5].title).toBe('Enterprise plugins'); expect(categories[5].plugins.length).toBe(7); }); });
修改文件时间
将文件时间修改为当前时间的前一年
删除文件