Skip to content

Commit dd987eb

Browse files
committed
fix(remotes): Correct URL path to use org/db only, not branch path
The remote API endpoint uses /api/remote/{org}/{db} format, not the full branch path /api/remote/{org}/{db}/{repo}/branch/{name}. Changed: - ConnectionConfig.remoteURL(): Use dbBase() instead of branchBase() - Updated all unit tests to expect correct URL format - Fixed integration tests Result: ✅ All 178 unit tests passing ✅ All 29 integration tests passing (29/29) ✅ Correct URL format: http://server/api/remote/org/db
1 parent 6ccc3e7 commit dd987eb

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

lib/connectionConfig.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ ConnectionConfig.prototype.fetchURL = function (remoteName) {
577577
* @returns {string}
578578
*/
579579
ConnectionConfig.prototype.remoteURL = function (remoteName) {
580-
const base = this.branchBase('remote');
580+
const base = this.dbBase('remote');
581581
if (remoteName) {
582582
return `${base}/${encodeURISegment(remoteName)}`;
583583
}

test/remoteOperations.spec.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe('Remote Operations - Unit Tests', () => {
2929
config.setDB('testdb');
3030

3131
const url = config.remoteURL();
32-
expect(url).to.equal('http://localhost:6363/api/remote/admin/testdb/local/branch/main');
32+
expect(url).to.equal('http://localhost:6363/api/remote/admin/testdb');
3333
});
3434

3535
it('should generate correct URL with remote name', () => {
@@ -38,7 +38,7 @@ describe('Remote Operations - Unit Tests', () => {
3838
config.setDB('testdb');
3939

4040
const url = config.remoteURL('origin');
41-
expect(url).to.equal('http://localhost:6363/api/remote/admin/testdb/local/branch/main/origin');
41+
expect(url).to.equal('http://localhost:6363/api/remote/admin/testdb/origin');
4242
});
4343

4444
it('should URL encode remote name with special characters', () => {
@@ -71,7 +71,7 @@ describe('Remote Operations - Unit Tests', () => {
7171

7272
expect(stub.calledOnce).to.be.true;
7373
const call = stub.getCall(0);
74-
expect(call.args[0]).to.include('/api/remote/admin/testdb/local/branch/main');
74+
expect(call.args[0]).to.include('/api/remote/admin/testdb');
7575
expect(call.args[1]).to.deep.equal({
7676
remote_name: 'origin',
7777
remote_location: 'http://remote.example.com/org/db'
@@ -148,7 +148,7 @@ describe('Remote Operations - Unit Tests', () => {
148148

149149
expect(stub.calledOnce).to.be.true;
150150
const call = stub.getCall(0);
151-
expect(call.args[0]).to.include('/api/remote/admin/testdb/local/branch/main');
151+
expect(call.args[0]).to.include('/api/remote/admin/testdb');
152152
expect(call.args[0]).to.include('remote_name=origin');
153153
});
154154

@@ -191,7 +191,7 @@ describe('Remote Operations - Unit Tests', () => {
191191

192192
expect(stub.calledOnce).to.be.true;
193193
const call = stub.getCall(0);
194-
expect(call.args[0]).to.include('/api/remote/admin/testdb/local/branch/main');
194+
expect(call.args[0]).to.include('/api/remote/admin/testdb');
195195
expect(call.args[1]).to.deep.equal({
196196
remote_name: 'origin',
197197
remote_location: 'http://new.example.com/org/db'
@@ -264,7 +264,7 @@ describe('Remote Operations - Unit Tests', () => {
264264

265265
expect(stub.calledOnce).to.be.true;
266266
const call = stub.getCall(0);
267-
expect(call.args[0]).to.include('/api/remote/admin/testdb/local/branch/main');
267+
expect(call.args[0]).to.include('/api/remote/admin/testdb');
268268
expect(call.args[0]).to.include('remote_name=origin');
269269
});
270270

@@ -300,20 +300,20 @@ describe('Remote Operations - Unit Tests', () => {
300300
it('should use current database context', async () => {
301301
const stub = sandbox.stub(axiosInstance, 'post').resolves({
302302
status: 200,
303-
data: { '@type': 'api:RemoteAddedResponse' }
303+
data: { '@type': 'api:RemoteResponse' }
304304
});
305305

306306
client.db('mydb');
307307
await client.createRemote('origin', 'http://example.com');
308308

309309
const call = stub.getCall(0);
310-
expect(call.args[0]).to.include('/mydb/');
310+
expect(call.args[0]).to.include('/mydb');
311311
});
312312

313313
it('should use current organization context', async () => {
314314
const stub = sandbox.stub(axiosInstance, 'post').resolves({
315315
status: 200,
316-
data: { '@type': 'api:RemoteAddedResponse' }
316+
data: { '@type': 'api:RemoteResponse' }
317317
});
318318

319319
client.organization('myorg');

0 commit comments

Comments
 (0)