Skip to main content
Glama

Redmine MCP Server

by yonaka15
delete.test.ts4.89 kB
import { jest, /*expect,*/ describe, it, beforeEach } from '@jest/globals'; import type { Mock } from 'jest-mock'; import { ProjectsClient } from '../../../client/projects.js'; // import { mockResponse, mockErrorResponse } from '../../helpers/mocks.js'; // Unused // import * as fixtures from '../../helpers/fixtures.js'; // Unused // import config from '../../../config.js'; // Unused // import { RedmineApiError } from '../../../client/base.js'; // Unused // import { parseUrl } from '../../helpers/url.js'; // Unused describe("Projects API (DELETE)", () => { // eslint-disable-next-line @typescript-eslint/no-unused-vars let client: ProjectsClient; // client is assigned but never used let mockFetch: Mock; beforeEach(() => { client = new ProjectsClient(); mockFetch = jest.spyOn(global, "fetch") as Mock; mockFetch.mockReset(); }); describe("DELETE /projects/:id.json (deleteProject)", () => { // DELETE操作のテストは安全のためスキップ it.skip("all DELETE operation tests are skipped for safety", () => { // DELETE操作のテストは、実際のAPIへの影響を避けるため、通常はモックサーバーを使用するか、 // または特定のテスト環境でのみ実行するように制御します。 // Redmine APIの仕様では、DELETEリクエストは成功すると204 No Contentを返します。 // 検証ポイント: // 1. プロジェクトのアーカイブ状態の検証 // - プロジェクトがアーカイブされている場合、削除可能か? // - プロジェクトがアクティブな場合、削除可能か?(通常はアーカイブが必要) // - APIの挙動として、アーカイブされていないプロジェクトを削除しようとした場合のレスポンス // 2. 関連データの検証 // - プロジェクトに紐づくチケット // - プロジェクトに紐づくWiki // - プロジェクトに紐づくニュース // - プロジェクトに紐づくファイル // - プロジェクトに紐づくリポジトリ // - プロジェクトに紐づく時間記録 // - プロジェクトに紐づくメンバーシップ // これらがどうなるか(またはどうすべきか)の確認。 // 3. 設定の検証 // - プロジェクト設定で削除が許可されているか。 // - ユーザー権限でプロジェクト削除が許可されているか。 // - システム全体の設定で削除が許可されているか。 // 4. 親プロジェクトとの関連 // - 子プロジェクトを持つ親プロジェクトを削除しようとした場合どうなるか。 // 通常、子プロジェクトの扱い(一緒に削除、親なしになる、削除不可など)を確認する必要がある。 // - 親プロジェクトが存在する場合、その親プロジェクトから正しく関連が切れるか。 // 5. エラー処理 // - 存在しないプロジェクトIDを指定した場合の404エラー // - 権限がない場合の403エラー // // 下記にテストのスケルトンを示します。 // 実際にテストを行う場合は、これらの点を考慮したモック戦略とアサーションが必要です。 }); }); }); // Example of how a test might look if it were enabled: /* import config from '../../../config.js'; import { RedmineApiError } from '../../../client/base.js'; import { mockErrorResponse } from '../../helpers/mocks.js'; it("deletes a project successfully (assuming it was archived)", async () => { // Arrange const projectIdToDelete = 123; // Assume this project is archived or deletion is allowed mockFetch.mockImplementationOnce(() => Promise.resolve(new Response(null, { status: 204 })) ); // Act await client.deleteProject(projectIdToDelete); // Assert expect(mockFetch).toHaveBeenCalledWith( `${config.redmineUrl}/projects/${projectIdToDelete}.json`, expect.objectContaining({ method: "DELETE", headers: expect.objectContaining({ "X-Redmine-API-Key": config.apiKey, }), }) ); }); it("handles error when trying to delete a non-existent project", async () => { // Arrange const projectIdToDelete = 99999; // Non-existent ID mockFetch.mockImplementationOnce(() => Promise.resolve(mockErrorResponse(404, ["Project not found"])) ); // Act & Assert await expect(client.deleteProject(projectIdToDelete)).rejects.toThrow(RedmineApiError); }); // Test for attempting to delete a project that is not archived (if API enforces this) // This would depend on specific Redmine settings and API behavior for non-archived projects. */

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/yonaka15/mcp-server-redmine'

If you have feedback or need assistance with the MCP directory API, please join our Discord server