@masonator/coolify-mcp 0.2.16 → 0.2.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -3
- package/dist/__tests__/coolify-client.test.d.ts +0 -1
- package/dist/__tests__/coolify-client.test.js +0 -208
- package/dist/__tests__/mcp-server.test.d.ts +0 -1
- package/dist/__tests__/mcp-server.test.js +0 -282
- package/dist/__tests__/resources/application-resources.test.d.ts +0 -1
- package/dist/__tests__/resources/application-resources.test.js +0 -33
- package/dist/__tests__/resources/database-resources.test.d.ts +0 -1
- package/dist/__tests__/resources/database-resources.test.js +0 -68
- package/dist/__tests__/resources/deployment-resources.test.d.ts +0 -1
- package/dist/__tests__/resources/deployment-resources.test.js +0 -46
- package/dist/__tests__/resources/service-resources.test.d.ts +0 -1
- package/dist/__tests__/resources/service-resources.test.js +0 -76
- package/dist/index.cjs +0 -1403
- package/dist/index.d.ts +0 -2
- package/dist/lib/coolify-client.d.ts +0 -44
- package/dist/lib/coolify-client.js +0 -161
- package/dist/lib/mcp-server.d.ts +0 -56
- package/dist/lib/mcp-server.js +0 -423
- package/dist/lib/resource.d.ts +0 -13
- package/dist/lib/resource.js +0 -25
- package/dist/resources/application-resources.d.ts +0 -14
- package/dist/resources/application-resources.js +0 -55
- package/dist/resources/database-resources.d.ts +0 -17
- package/dist/resources/database-resources.js +0 -51
- package/dist/resources/deployment-resources.d.ts +0 -12
- package/dist/resources/deployment-resources.js +0 -44
- package/dist/resources/index.d.ts +0 -4
- package/dist/resources/index.js +0 -4
- package/dist/resources/service-resources.d.ts +0 -15
- package/dist/resources/service-resources.js +0 -51
- package/dist/types/coolify.d.ts +0 -228
- package/dist/types/coolify.js +0 -1
package/package.json
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@masonator/coolify-mcp",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.18",
|
|
4
4
|
"description": "Model Context Protocol server for Coolify",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"
|
|
7
|
-
"bin":
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"coolify-mcp": "./dist/index.js"
|
|
9
|
+
},
|
|
8
10
|
"files": [
|
|
9
11
|
"dist"
|
|
10
12
|
],
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
import { jest } from '@jest/globals';
|
|
2
|
-
import { CoolifyClient } from '../lib/coolify-client.js';
|
|
3
|
-
const mockFetch = jest.fn();
|
|
4
|
-
describe('CoolifyClient', () => {
|
|
5
|
-
let client;
|
|
6
|
-
const mockServers = [
|
|
7
|
-
{
|
|
8
|
-
id: 1,
|
|
9
|
-
uuid: 'test-uuid',
|
|
10
|
-
name: 'test-server',
|
|
11
|
-
status: 'running',
|
|
12
|
-
},
|
|
13
|
-
];
|
|
14
|
-
const mockServerInfo = {
|
|
15
|
-
id: 1,
|
|
16
|
-
uuid: 'test-uuid',
|
|
17
|
-
name: 'test-server',
|
|
18
|
-
status: 'running',
|
|
19
|
-
};
|
|
20
|
-
const mockServerResources = {
|
|
21
|
-
resources: [
|
|
22
|
-
{
|
|
23
|
-
name: 'memory',
|
|
24
|
-
value: '2GB',
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
name: 'disk',
|
|
28
|
-
value: '20GB',
|
|
29
|
-
},
|
|
30
|
-
],
|
|
31
|
-
};
|
|
32
|
-
const mockService = {
|
|
33
|
-
id: 1,
|
|
34
|
-
uuid: 'test-uuid',
|
|
35
|
-
name: 'test-service',
|
|
36
|
-
type: 'code-server',
|
|
37
|
-
status: 'running',
|
|
38
|
-
created_at: '2024-01-01',
|
|
39
|
-
updated_at: '2024-01-01',
|
|
40
|
-
};
|
|
41
|
-
const errorResponse = {
|
|
42
|
-
message: 'Resource not found',
|
|
43
|
-
};
|
|
44
|
-
beforeEach(() => {
|
|
45
|
-
mockFetch.mockClear();
|
|
46
|
-
global.fetch = mockFetch;
|
|
47
|
-
client = new CoolifyClient({
|
|
48
|
-
baseUrl: 'http://localhost:3000',
|
|
49
|
-
accessToken: 'test-api-key',
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
describe('listServers', () => {
|
|
53
|
-
it('should return a list of servers', async () => {
|
|
54
|
-
mockFetch.mockImplementationOnce(async () => ({
|
|
55
|
-
ok: true,
|
|
56
|
-
json: async () => mockServers,
|
|
57
|
-
}));
|
|
58
|
-
const servers = await client.listServers();
|
|
59
|
-
expect(servers).toEqual(mockServers);
|
|
60
|
-
expect(mockFetch).toHaveBeenCalledWith('http://localhost:3000/api/v1/servers', {
|
|
61
|
-
headers: {
|
|
62
|
-
'Content-Type': 'application/json',
|
|
63
|
-
Authorization: 'Bearer test-api-key',
|
|
64
|
-
},
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
it('should handle errors', async () => {
|
|
68
|
-
mockFetch.mockImplementationOnce(() => Promise.resolve({
|
|
69
|
-
ok: false,
|
|
70
|
-
json: async () => errorResponse,
|
|
71
|
-
}));
|
|
72
|
-
await expect(client.listServers()).rejects.toThrow('Resource not found');
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
describe('getServer', () => {
|
|
76
|
-
it('should get server info', async () => {
|
|
77
|
-
mockFetch.mockImplementationOnce(() => Promise.resolve({
|
|
78
|
-
ok: true,
|
|
79
|
-
json: async () => mockServerInfo,
|
|
80
|
-
}));
|
|
81
|
-
const result = await client.getServer('test-uuid');
|
|
82
|
-
expect(result).toEqual(mockServerInfo);
|
|
83
|
-
expect(mockFetch).toHaveBeenCalledWith('http://localhost:3000/api/v1/servers/test-uuid', {
|
|
84
|
-
headers: {
|
|
85
|
-
'Content-Type': 'application/json',
|
|
86
|
-
Authorization: 'Bearer test-api-key',
|
|
87
|
-
},
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
it('should handle errors', async () => {
|
|
91
|
-
mockFetch.mockImplementationOnce(() => Promise.resolve({
|
|
92
|
-
ok: false,
|
|
93
|
-
json: async () => errorResponse,
|
|
94
|
-
}));
|
|
95
|
-
await expect(client.getServer('test-uuid')).rejects.toThrow('Resource not found');
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
describe('getServerResources', () => {
|
|
99
|
-
it('should get server resources', async () => {
|
|
100
|
-
mockFetch.mockImplementationOnce(() => Promise.resolve({
|
|
101
|
-
ok: true,
|
|
102
|
-
json: async () => mockServerResources,
|
|
103
|
-
}));
|
|
104
|
-
const result = await client.getServerResources('test-uuid');
|
|
105
|
-
expect(result).toEqual(mockServerResources);
|
|
106
|
-
expect(mockFetch).toHaveBeenCalledWith('http://localhost:3000/api/v1/servers/test-uuid/resources', {
|
|
107
|
-
headers: {
|
|
108
|
-
'Content-Type': 'application/json',
|
|
109
|
-
Authorization: 'Bearer test-api-key',
|
|
110
|
-
},
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
it('should handle errors', async () => {
|
|
114
|
-
mockFetch.mockImplementationOnce(() => Promise.resolve({
|
|
115
|
-
ok: false,
|
|
116
|
-
json: async () => errorResponse,
|
|
117
|
-
}));
|
|
118
|
-
await expect(client.getServerResources('test-uuid')).rejects.toThrow('Resource not found');
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
describe('listServices', () => {
|
|
122
|
-
it('should list services', async () => {
|
|
123
|
-
mockFetch.mockImplementationOnce(() => Promise.resolve({
|
|
124
|
-
ok: true,
|
|
125
|
-
json: () => Promise.resolve([mockService]),
|
|
126
|
-
}));
|
|
127
|
-
const result = await client.listServices();
|
|
128
|
-
expect(result).toEqual([mockService]);
|
|
129
|
-
expect(mockFetch).toHaveBeenCalledWith('http://localhost:3000/api/v1/services', {
|
|
130
|
-
headers: {
|
|
131
|
-
'Content-Type': 'application/json',
|
|
132
|
-
Authorization: 'Bearer test-api-key',
|
|
133
|
-
},
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
});
|
|
137
|
-
describe('getService', () => {
|
|
138
|
-
it('should get service info', async () => {
|
|
139
|
-
mockFetch.mockImplementationOnce(() => Promise.resolve({
|
|
140
|
-
ok: true,
|
|
141
|
-
json: () => Promise.resolve(mockService),
|
|
142
|
-
}));
|
|
143
|
-
const result = await client.getService('test-uuid');
|
|
144
|
-
expect(result).toEqual(mockService);
|
|
145
|
-
expect(mockFetch).toHaveBeenCalledWith('http://localhost:3000/api/v1/services/test-uuid', {
|
|
146
|
-
headers: {
|
|
147
|
-
'Content-Type': 'application/json',
|
|
148
|
-
Authorization: 'Bearer test-api-key',
|
|
149
|
-
},
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
describe('createService', () => {
|
|
154
|
-
it('should create a service', async () => {
|
|
155
|
-
mockFetch.mockImplementationOnce(() => Promise.resolve({
|
|
156
|
-
ok: true,
|
|
157
|
-
json: () => Promise.resolve({
|
|
158
|
-
uuid: 'test-uuid',
|
|
159
|
-
domains: ['test.com'],
|
|
160
|
-
}),
|
|
161
|
-
}));
|
|
162
|
-
const createData = {
|
|
163
|
-
name: 'test-service',
|
|
164
|
-
type: 'code-server',
|
|
165
|
-
project_uuid: 'project-uuid',
|
|
166
|
-
environment_uuid: 'env-uuid',
|
|
167
|
-
server_uuid: 'server-uuid',
|
|
168
|
-
};
|
|
169
|
-
const result = await client.createService(createData);
|
|
170
|
-
expect(result).toEqual({
|
|
171
|
-
uuid: 'test-uuid',
|
|
172
|
-
domains: ['test.com'],
|
|
173
|
-
});
|
|
174
|
-
expect(mockFetch).toHaveBeenCalledWith('http://localhost:3000/api/v1/services', {
|
|
175
|
-
method: 'POST',
|
|
176
|
-
headers: {
|
|
177
|
-
'Content-Type': 'application/json',
|
|
178
|
-
Authorization: 'Bearer test-api-key',
|
|
179
|
-
},
|
|
180
|
-
body: JSON.stringify(createData),
|
|
181
|
-
});
|
|
182
|
-
});
|
|
183
|
-
});
|
|
184
|
-
describe('deleteService', () => {
|
|
185
|
-
it('should delete a service', async () => {
|
|
186
|
-
mockFetch.mockImplementationOnce(() => Promise.resolve({
|
|
187
|
-
ok: true,
|
|
188
|
-
json: () => Promise.resolve({ message: 'Service deleted' }),
|
|
189
|
-
}));
|
|
190
|
-
const result = await client.deleteService('test-uuid');
|
|
191
|
-
expect(result).toEqual({ message: 'Service deleted' });
|
|
192
|
-
expect(mockFetch).toHaveBeenCalledWith('http://localhost:3000/api/v1/services/test-uuid', {
|
|
193
|
-
method: 'DELETE',
|
|
194
|
-
headers: {
|
|
195
|
-
'Content-Type': 'application/json',
|
|
196
|
-
Authorization: 'Bearer test-api-key',
|
|
197
|
-
},
|
|
198
|
-
});
|
|
199
|
-
});
|
|
200
|
-
});
|
|
201
|
-
describe('error handling', () => {
|
|
202
|
-
it('should handle network errors', async () => {
|
|
203
|
-
const errorMessage = 'Network error';
|
|
204
|
-
mockFetch.mockImplementationOnce(() => Promise.reject(new Error(errorMessage)));
|
|
205
|
-
await expect(client.listServers()).rejects.toThrow(errorMessage);
|
|
206
|
-
});
|
|
207
|
-
});
|
|
208
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,282 +0,0 @@
|
|
|
1
|
-
import { CoolifyMcpServer } from '../lib/mcp-server.js';
|
|
2
|
-
import { jest } from '@jest/globals';
|
|
3
|
-
describe('CoolifyMcpServer', () => {
|
|
4
|
-
const mockConfig = {
|
|
5
|
-
baseUrl: 'https://coolify.test',
|
|
6
|
-
accessToken: 'test-token',
|
|
7
|
-
};
|
|
8
|
-
let server;
|
|
9
|
-
beforeEach(() => {
|
|
10
|
-
server = new CoolifyMcpServer(mockConfig);
|
|
11
|
-
// Mock validateConnection to prevent actual HTTP calls
|
|
12
|
-
jest.spyOn(server['client'], 'validateConnection').mockResolvedValue();
|
|
13
|
-
});
|
|
14
|
-
describe('get_server_resources', () => {
|
|
15
|
-
it('should call client getServerResources', async () => {
|
|
16
|
-
// Mock the method before calling it
|
|
17
|
-
const mockResources = [
|
|
18
|
-
{
|
|
19
|
-
id: 1,
|
|
20
|
-
uuid: 'test-resource-uuid',
|
|
21
|
-
name: 'test-resource',
|
|
22
|
-
type: 'application',
|
|
23
|
-
created_at: '2024-03-20T00:00:00Z',
|
|
24
|
-
updated_at: '2024-03-20T00:00:00Z',
|
|
25
|
-
status: 'running',
|
|
26
|
-
},
|
|
27
|
-
];
|
|
28
|
-
const spy = jest
|
|
29
|
-
.spyOn(server['client'], 'getServerResources')
|
|
30
|
-
.mockResolvedValue(mockResources);
|
|
31
|
-
await server.get_server_resources('test-uuid');
|
|
32
|
-
expect(spy).toHaveBeenCalledWith('test-uuid');
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
describe('validate_server', () => {
|
|
36
|
-
it('should call client validateServer', async () => {
|
|
37
|
-
// Mock the method before calling it
|
|
38
|
-
const mockValidation = {
|
|
39
|
-
message: 'Server is valid',
|
|
40
|
-
};
|
|
41
|
-
const spy = jest.spyOn(server['client'], 'validateServer').mockResolvedValue(mockValidation);
|
|
42
|
-
await server.validate_server('test-uuid');
|
|
43
|
-
expect(spy).toHaveBeenCalledWith('test-uuid');
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
describe('list_projects', () => {
|
|
47
|
-
it('should call client listProjects', async () => {
|
|
48
|
-
const mockProjects = [
|
|
49
|
-
{
|
|
50
|
-
id: 1,
|
|
51
|
-
uuid: 'test-project-uuid',
|
|
52
|
-
name: 'test-project',
|
|
53
|
-
description: 'Test project description',
|
|
54
|
-
environments: [],
|
|
55
|
-
},
|
|
56
|
-
];
|
|
57
|
-
const spy = jest.spyOn(server['client'], 'listProjects').mockResolvedValue(mockProjects);
|
|
58
|
-
await server.list_projects();
|
|
59
|
-
expect(spy).toHaveBeenCalled();
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
describe('get_project', () => {
|
|
63
|
-
it('should call client getProject', async () => {
|
|
64
|
-
const mockProject = {
|
|
65
|
-
id: 1,
|
|
66
|
-
uuid: 'test-project-uuid',
|
|
67
|
-
name: 'test-project',
|
|
68
|
-
description: 'Test project description',
|
|
69
|
-
environments: [],
|
|
70
|
-
};
|
|
71
|
-
const spy = jest.spyOn(server['client'], 'getProject').mockResolvedValue(mockProject);
|
|
72
|
-
await server.get_project('test-project-uuid');
|
|
73
|
-
expect(spy).toHaveBeenCalledWith('test-project-uuid');
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
describe('create_project', () => {
|
|
77
|
-
it('should call client createProject', async () => {
|
|
78
|
-
const mockResponse = { uuid: 'new-project-uuid' };
|
|
79
|
-
const createRequest = {
|
|
80
|
-
name: 'New Project',
|
|
81
|
-
description: 'New project description',
|
|
82
|
-
};
|
|
83
|
-
const spy = jest.spyOn(server['client'], 'createProject').mockResolvedValue(mockResponse);
|
|
84
|
-
await server.create_project(createRequest);
|
|
85
|
-
expect(spy).toHaveBeenCalledWith(createRequest);
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
describe('update_project', () => {
|
|
89
|
-
it('should call client updateProject', async () => {
|
|
90
|
-
const mockProject = {
|
|
91
|
-
id: 1,
|
|
92
|
-
uuid: 'test-project-uuid',
|
|
93
|
-
name: 'Updated Project',
|
|
94
|
-
description: 'Updated description',
|
|
95
|
-
environments: [],
|
|
96
|
-
};
|
|
97
|
-
const updateRequest = {
|
|
98
|
-
name: 'Updated Project',
|
|
99
|
-
description: 'Updated description',
|
|
100
|
-
};
|
|
101
|
-
const spy = jest.spyOn(server['client'], 'updateProject').mockResolvedValue(mockProject);
|
|
102
|
-
await server.update_project('test-project-uuid', updateRequest);
|
|
103
|
-
expect(spy).toHaveBeenCalledWith('test-project-uuid', updateRequest);
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
describe('delete_project', () => {
|
|
107
|
-
it('should call client deleteProject', async () => {
|
|
108
|
-
const mockResponse = { message: 'Project deleted successfully' };
|
|
109
|
-
const spy = jest.spyOn(server['client'], 'deleteProject').mockResolvedValue(mockResponse);
|
|
110
|
-
await server.delete_project('test-project-uuid');
|
|
111
|
-
expect(spy).toHaveBeenCalledWith('test-project-uuid');
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
describe('get_project_environment', () => {
|
|
115
|
-
it('should call client getProjectEnvironment', async () => {
|
|
116
|
-
const mockEnvironment = {
|
|
117
|
-
id: 1,
|
|
118
|
-
uuid: 'test-env-uuid',
|
|
119
|
-
name: 'test-env',
|
|
120
|
-
project_uuid: 'test-project-uuid',
|
|
121
|
-
variables: { KEY: 'value' },
|
|
122
|
-
created_at: '2024-03-06T12:00:00Z',
|
|
123
|
-
updated_at: '2024-03-06T12:00:00Z',
|
|
124
|
-
};
|
|
125
|
-
const spy = jest
|
|
126
|
-
.spyOn(server['client'], 'getProjectEnvironment')
|
|
127
|
-
.mockResolvedValue(mockEnvironment);
|
|
128
|
-
await server.get_project_environment('test-project-uuid', 'test-env-uuid');
|
|
129
|
-
expect(spy).toHaveBeenCalledWith('test-project-uuid', 'test-env-uuid');
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
describe('deploy_application', () => {
|
|
133
|
-
it('should deploy an application', async () => {
|
|
134
|
-
const mockDeployment = {
|
|
135
|
-
id: 1,
|
|
136
|
-
uuid: 'test-deployment-uuid',
|
|
137
|
-
application_uuid: 'test-app-uuid',
|
|
138
|
-
status: 'running',
|
|
139
|
-
created_at: '2024-03-20T12:00:00Z',
|
|
140
|
-
updated_at: '2024-03-20T12:00:00Z',
|
|
141
|
-
};
|
|
142
|
-
jest.spyOn(server['client'], 'deployApplication').mockResolvedValue(mockDeployment);
|
|
143
|
-
const result = await server.deploy_application({ uuid: 'test-app-uuid' });
|
|
144
|
-
expect(result).toEqual(mockDeployment);
|
|
145
|
-
expect(server['client'].deployApplication).toHaveBeenCalledWith('test-app-uuid');
|
|
146
|
-
});
|
|
147
|
-
it('should handle errors when deploying an application', async () => {
|
|
148
|
-
const error = new Error('Failed to deploy application');
|
|
149
|
-
jest.spyOn(server['client'], 'deployApplication').mockRejectedValue(error);
|
|
150
|
-
await expect(server.deploy_application({ uuid: 'test-app-uuid' })).rejects.toThrow('Failed to deploy application');
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
describe('Database Management', () => {
|
|
154
|
-
const mockDatabase = {
|
|
155
|
-
id: 1,
|
|
156
|
-
uuid: 'test-db-uuid',
|
|
157
|
-
name: 'test-db',
|
|
158
|
-
description: 'Test database',
|
|
159
|
-
type: 'postgresql',
|
|
160
|
-
status: 'running',
|
|
161
|
-
created_at: '2024-03-06T12:00:00Z',
|
|
162
|
-
updated_at: '2024-03-06T12:00:00Z',
|
|
163
|
-
is_public: false,
|
|
164
|
-
image: 'postgres:latest',
|
|
165
|
-
postgres_user: 'postgres',
|
|
166
|
-
postgres_password: 'test123',
|
|
167
|
-
postgres_db: 'testdb',
|
|
168
|
-
};
|
|
169
|
-
it('should list databases', async () => {
|
|
170
|
-
const spy = jest.spyOn(server['client'], 'listDatabases').mockResolvedValue([mockDatabase]);
|
|
171
|
-
const result = await server.list_databases();
|
|
172
|
-
expect(result).toEqual([mockDatabase]);
|
|
173
|
-
expect(spy).toHaveBeenCalled();
|
|
174
|
-
});
|
|
175
|
-
it('should get database details', async () => {
|
|
176
|
-
const spy = jest.spyOn(server['client'], 'getDatabase').mockResolvedValue(mockDatabase);
|
|
177
|
-
const result = await server.get_database('test-db-uuid');
|
|
178
|
-
expect(result).toEqual(mockDatabase);
|
|
179
|
-
expect(spy).toHaveBeenCalledWith('test-db-uuid');
|
|
180
|
-
});
|
|
181
|
-
it('should update database', async () => {
|
|
182
|
-
const updateData = {
|
|
183
|
-
name: 'updated-db',
|
|
184
|
-
description: 'Updated description',
|
|
185
|
-
};
|
|
186
|
-
const spy = jest
|
|
187
|
-
.spyOn(server['client'], 'updateDatabase')
|
|
188
|
-
.mockResolvedValue({ ...mockDatabase, ...updateData, type: 'postgresql' });
|
|
189
|
-
const result = await server.update_database('test-db-uuid', updateData);
|
|
190
|
-
expect(result).toEqual({
|
|
191
|
-
...mockDatabase,
|
|
192
|
-
...updateData,
|
|
193
|
-
type: 'postgresql',
|
|
194
|
-
});
|
|
195
|
-
expect(spy).toHaveBeenCalledWith('test-db-uuid', updateData);
|
|
196
|
-
});
|
|
197
|
-
it('should delete database', async () => {
|
|
198
|
-
const mockResponse = { message: 'Database deleted' };
|
|
199
|
-
const spy = jest.spyOn(server['client'], 'deleteDatabase').mockResolvedValue(mockResponse);
|
|
200
|
-
const result = await server.delete_database('test-db-uuid', {
|
|
201
|
-
deleteConfigurations: true,
|
|
202
|
-
deleteVolumes: true,
|
|
203
|
-
});
|
|
204
|
-
expect(result).toEqual(mockResponse);
|
|
205
|
-
expect(spy).toHaveBeenCalledWith('test-db-uuid', {
|
|
206
|
-
deleteConfigurations: true,
|
|
207
|
-
deleteVolumes: true,
|
|
208
|
-
});
|
|
209
|
-
});
|
|
210
|
-
it('should handle database errors', async () => {
|
|
211
|
-
const errorMessage = 'Database not found';
|
|
212
|
-
jest.spyOn(server['client'], 'getDatabase').mockRejectedValue(new Error(errorMessage));
|
|
213
|
-
await expect(server.get_database('invalid-uuid')).rejects.toThrow(errorMessage);
|
|
214
|
-
});
|
|
215
|
-
});
|
|
216
|
-
describe('Service Management', () => {
|
|
217
|
-
const mockService = {
|
|
218
|
-
id: 1,
|
|
219
|
-
uuid: 'test-service-uuid',
|
|
220
|
-
name: 'test-service',
|
|
221
|
-
description: 'Test service',
|
|
222
|
-
type: 'code-server',
|
|
223
|
-
status: 'running',
|
|
224
|
-
created_at: '2024-03-06T12:00:00Z',
|
|
225
|
-
updated_at: '2024-03-06T12:00:00Z',
|
|
226
|
-
project_uuid: 'test-project-uuid',
|
|
227
|
-
environment_name: 'production',
|
|
228
|
-
environment_uuid: 'test-env-uuid',
|
|
229
|
-
server_uuid: 'test-server-uuid',
|
|
230
|
-
domains: ['test-service.example.com'],
|
|
231
|
-
};
|
|
232
|
-
it('should list services', async () => {
|
|
233
|
-
const spy = jest.spyOn(server['client'], 'listServices').mockResolvedValue([mockService]);
|
|
234
|
-
const result = await server.list_services();
|
|
235
|
-
expect(result).toEqual([mockService]);
|
|
236
|
-
expect(spy).toHaveBeenCalled();
|
|
237
|
-
});
|
|
238
|
-
it('should get service details', async () => {
|
|
239
|
-
const spy = jest.spyOn(server['client'], 'getService').mockResolvedValue(mockService);
|
|
240
|
-
const result = await server.get_service('test-service-uuid');
|
|
241
|
-
expect(result).toEqual(mockService);
|
|
242
|
-
expect(spy).toHaveBeenCalledWith('test-service-uuid');
|
|
243
|
-
});
|
|
244
|
-
it('should create service', async () => {
|
|
245
|
-
const createData = {
|
|
246
|
-
type: 'code-server',
|
|
247
|
-
name: 'test-service',
|
|
248
|
-
description: 'Test service',
|
|
249
|
-
project_uuid: 'test-project-uuid',
|
|
250
|
-
environment_name: 'production',
|
|
251
|
-
server_uuid: 'test-server-uuid',
|
|
252
|
-
instant_deploy: true,
|
|
253
|
-
};
|
|
254
|
-
const mockResponse = {
|
|
255
|
-
uuid: 'test-service-uuid',
|
|
256
|
-
domains: ['test-service.example.com'],
|
|
257
|
-
};
|
|
258
|
-
const spy = jest.spyOn(server['client'], 'createService').mockResolvedValue(mockResponse);
|
|
259
|
-
const result = await server.create_service(createData);
|
|
260
|
-
expect(result).toEqual(mockResponse);
|
|
261
|
-
expect(spy).toHaveBeenCalledWith(createData);
|
|
262
|
-
});
|
|
263
|
-
it('should delete service', async () => {
|
|
264
|
-
const mockResponse = { message: 'Service deleted' };
|
|
265
|
-
const spy = jest.spyOn(server['client'], 'deleteService').mockResolvedValue(mockResponse);
|
|
266
|
-
const result = await server.delete_service('test-service-uuid', {
|
|
267
|
-
deleteConfigurations: true,
|
|
268
|
-
deleteVolumes: true,
|
|
269
|
-
});
|
|
270
|
-
expect(result).toEqual(mockResponse);
|
|
271
|
-
expect(spy).toHaveBeenCalledWith('test-service-uuid', {
|
|
272
|
-
deleteConfigurations: true,
|
|
273
|
-
deleteVolumes: true,
|
|
274
|
-
});
|
|
275
|
-
});
|
|
276
|
-
it('should handle service errors', async () => {
|
|
277
|
-
const errorMessage = 'Service not found';
|
|
278
|
-
jest.spyOn(server['client'], 'getService').mockRejectedValue(new Error(errorMessage));
|
|
279
|
-
await expect(server.get_service('invalid-uuid')).rejects.toThrow(errorMessage);
|
|
280
|
-
});
|
|
281
|
-
});
|
|
282
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { ApplicationResources } from '../../resources/application-resources.js';
|
|
2
|
-
import { jest } from '@jest/globals';
|
|
3
|
-
jest.mock('../../lib/coolify-client.js');
|
|
4
|
-
describe('ApplicationResources', () => {
|
|
5
|
-
let resources;
|
|
6
|
-
let mockClient;
|
|
7
|
-
beforeEach(() => {
|
|
8
|
-
mockClient = {
|
|
9
|
-
deployApplication: jest.fn(),
|
|
10
|
-
};
|
|
11
|
-
resources = new ApplicationResources(mockClient);
|
|
12
|
-
});
|
|
13
|
-
describe('listApplications', () => {
|
|
14
|
-
it('should throw not implemented error', async () => {
|
|
15
|
-
await expect(resources.listApplications()).rejects.toThrow('Not implemented');
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
describe('getApplication', () => {
|
|
19
|
-
it('should throw not implemented error', async () => {
|
|
20
|
-
await expect(resources.getApplication('test-id')).rejects.toThrow('Not implemented');
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
describe('createApplication', () => {
|
|
24
|
-
it('should throw not implemented error', async () => {
|
|
25
|
-
await expect(resources.createApplication({ name: 'test-app' })).rejects.toThrow('Not implemented');
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
describe('deleteApplication', () => {
|
|
29
|
-
it('should throw not implemented error', async () => {
|
|
30
|
-
await expect(resources.deleteApplication('test-id')).rejects.toThrow('Not implemented');
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { DatabaseResources } from '../../resources/database-resources.js';
|
|
2
|
-
import { jest } from '@jest/globals';
|
|
3
|
-
jest.mock('../../lib/coolify-client.js');
|
|
4
|
-
describe('DatabaseResources', () => {
|
|
5
|
-
let mockClient;
|
|
6
|
-
let resources;
|
|
7
|
-
const mockDatabase = {
|
|
8
|
-
id: 1,
|
|
9
|
-
uuid: 'test-uuid',
|
|
10
|
-
name: 'test-db',
|
|
11
|
-
description: 'test description',
|
|
12
|
-
type: 'postgresql',
|
|
13
|
-
status: 'running',
|
|
14
|
-
created_at: '2024-01-01',
|
|
15
|
-
updated_at: '2024-01-01',
|
|
16
|
-
is_public: false,
|
|
17
|
-
image: 'postgres:latest',
|
|
18
|
-
postgres_user: 'test',
|
|
19
|
-
postgres_password: 'test',
|
|
20
|
-
postgres_db: 'test',
|
|
21
|
-
};
|
|
22
|
-
beforeEach(() => {
|
|
23
|
-
mockClient = {
|
|
24
|
-
listDatabases: jest.fn(),
|
|
25
|
-
getDatabase: jest.fn(),
|
|
26
|
-
updateDatabase: jest.fn(),
|
|
27
|
-
deleteDatabase: jest.fn(),
|
|
28
|
-
};
|
|
29
|
-
resources = new DatabaseResources(mockClient);
|
|
30
|
-
});
|
|
31
|
-
describe('listDatabases', () => {
|
|
32
|
-
it('should return a list of databases', async () => {
|
|
33
|
-
mockClient.listDatabases.mockResolvedValue([mockDatabase]);
|
|
34
|
-
const result = await resources.listDatabases();
|
|
35
|
-
expect(result).toEqual([mockDatabase]);
|
|
36
|
-
expect(mockClient.listDatabases).toHaveBeenCalled();
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
describe('getDatabase', () => {
|
|
40
|
-
it('should return a database by uuid', async () => {
|
|
41
|
-
mockClient.getDatabase.mockResolvedValue(mockDatabase);
|
|
42
|
-
const result = await resources.getDatabase('test-uuid');
|
|
43
|
-
expect(result).toEqual(mockDatabase);
|
|
44
|
-
expect(mockClient.getDatabase).toHaveBeenCalledWith('test-uuid');
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
describe('updateDatabase', () => {
|
|
48
|
-
it('should update a database', async () => {
|
|
49
|
-
const updateData = {
|
|
50
|
-
name: 'updated-db',
|
|
51
|
-
description: 'updated description',
|
|
52
|
-
};
|
|
53
|
-
mockClient.updateDatabase.mockResolvedValue({ ...mockDatabase, ...updateData });
|
|
54
|
-
const result = await resources.updateDatabase('test-uuid', updateData);
|
|
55
|
-
expect(result).toEqual({ ...mockDatabase, ...updateData });
|
|
56
|
-
expect(mockClient.updateDatabase).toHaveBeenCalledWith('test-uuid', updateData);
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
describe('deleteDatabase', () => {
|
|
60
|
-
it('should delete a database', async () => {
|
|
61
|
-
const mockResponse = { message: 'Database deleted successfully' };
|
|
62
|
-
mockClient.deleteDatabase.mockResolvedValue(mockResponse);
|
|
63
|
-
const result = await resources.deleteDatabase('test-uuid', {});
|
|
64
|
-
expect(result).toEqual(mockResponse);
|
|
65
|
-
expect(mockClient.deleteDatabase).toHaveBeenCalledWith('test-uuid', {});
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { DeploymentResources } from '../../resources/deployment-resources.js';
|
|
2
|
-
import { jest } from '@jest/globals';
|
|
3
|
-
jest.mock('../../lib/coolify-client.js');
|
|
4
|
-
describe('DeploymentResources', () => {
|
|
5
|
-
let mockClient;
|
|
6
|
-
let resources;
|
|
7
|
-
const mockDeployment = {
|
|
8
|
-
id: 1,
|
|
9
|
-
uuid: 'test-uuid',
|
|
10
|
-
status: 'running',
|
|
11
|
-
created_at: '2024-01-01',
|
|
12
|
-
updated_at: '2024-01-01',
|
|
13
|
-
application_uuid: 'app-uuid',
|
|
14
|
-
environment_uuid: 'env-uuid',
|
|
15
|
-
};
|
|
16
|
-
beforeEach(() => {
|
|
17
|
-
mockClient = {
|
|
18
|
-
deployApplication: jest.fn(),
|
|
19
|
-
};
|
|
20
|
-
resources = new DeploymentResources(mockClient);
|
|
21
|
-
});
|
|
22
|
-
describe('listDeployments', () => {
|
|
23
|
-
it('should throw not implemented error', async () => {
|
|
24
|
-
await expect(resources.listDeployments()).rejects.toThrow('Not implemented');
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
describe('getDeployment', () => {
|
|
28
|
-
it('should throw not implemented error', async () => {
|
|
29
|
-
await expect(resources.getDeployment('test-id')).rejects.toThrow('Not implemented');
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
describe('deploy', () => {
|
|
33
|
-
it('should deploy an application', async () => {
|
|
34
|
-
mockClient.deployApplication.mockResolvedValue(mockDeployment);
|
|
35
|
-
const result = await resources.deploy({ uuid: 'test-uuid' });
|
|
36
|
-
expect(result).toEqual(mockDeployment);
|
|
37
|
-
expect(mockClient.deployApplication).toHaveBeenCalledWith('test-uuid');
|
|
38
|
-
});
|
|
39
|
-
it('should handle deployment errors', async () => {
|
|
40
|
-
const error = new Error('Deployment failed');
|
|
41
|
-
mockClient.deployApplication.mockRejectedValue(error);
|
|
42
|
-
await expect(resources.deploy({ uuid: 'test-uuid' })).rejects.toThrow('Deployment failed');
|
|
43
|
-
expect(mockClient.deployApplication).toHaveBeenCalledWith('test-uuid');
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|