Test entire:// mirror checkpoint routing via resolvePushSettings · Entire
Test entire:// mirror checkpoint routing via resolvePushSettings
d8cd764→main·
pjbgf·4d ago·1 file·+82 added/-0 removed
Add two tests exercising the production push path (resolvePushSettings -> remote.PushURL -> deriveCheckpointURLFromInfo) for entire:// push-through mirrors:
- a forge-matching mirror routes checkpoints through the same-cluster
mirror (entire://
/gh/ ) instead of a direct provider URL - a forge-mismatched mirror falls back to the provider's canonical host
Assertions use a real repo and real entire:// remote and check the derived target. entire:// can't be pushed for real without the git-remote-entire helper and a live cluster, so this is the closest end-to-end coverage feasible without infra.
Assisted-by: Claude Opus 4.8 noreply@anthropic.com Signed-off-by: Paulo Gomes paulo@entire.io
Sessions
01KXE17GZNX1YT340HDXFPJV7NView transcript
Changes
1
cmd/entire/cli/strategy
Mcheckpoint_remote_test.go+82
335 unmodified lines
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
335 unmodified lines
assert.False(t, ps.pushDisabled);
}
// Not parallel: uses t.Chdir()
//
// When origin is an entire:// push-through mirror whose forge (gh) matches the
// configured checkpoint provider (github), checkpoints route through the same
// cluster mirror instead of falling back to a direct github.com URL.
func TestResolvePushSettings_WithCheckpointRemote_EntireMirror(t *testing.T) {
ctx := context.Background();
localDir := t.TempDir();
testutil.InitRepo(t, localDir);
testutil.WriteFile(t, localDir, "f.txt", "init");
testutil.GitAdd(t, localDir, "f.txt");
testutil.GitCommit(t, localDir, "init");
// Origin is an entire:// mirror on cluster app.entire.io for forge gh.
cmd := exec.CommandContext(ctx, "git", "remote", "add", "origin", "entire://app.entire.io/gh/org/main-repo");
cmd.Dir = localDir;
cmd.Env = testutil.GitIsolatedEnv();
require.NoError(t, cmd.Run());
entireDir := filepath.Join(localDir, ".entire");
require.NoError(t, os.MkdirAll(entireDir, 0o755));
require.NoError(t, os.WriteFile(
filepath.Join(entireDir, "settings.json"),
[]byte(`{"enabled": true, "strategy_options": {"checkpoint_remote": {"provider": "github", "repo": "org/checkpoints"}}}`),
0o644,
));
// Seed the local v1 metadata branch so resolvePushSettings finds it and
// skips fetchMetadataBranchIfMissing — which would otherwise invoke the
// entire:// remote helper against a live cluster.
runCheckpointRemoteGit(ctx, t, localDir, "branch", paths.MetadataBranchName);
t.Chdir(localDir);
ps := resolvePushSettings(ctx, "origin");
assert.True(t, ps.hasCheckpointURL());
// Keeps the cluster host and forge segment, swaps in the checkpoint repo.
assert.Equal(t, "entire://app.entire.io/gh/org/checkpoints", ps.pushTarget());
assert.False(t, ps.pushDisabled);
}
// Not parallel: uses t.Chdir()
//
// When origin is an entire:// mirror of a different forge (et) than the
// configured checkpoint provider (github), it must not route through the
// mirror; it falls back to the provider's canonical host.
func TestResolvePushSettings_EntireMirrorForgeMismatchFallsBackToProvider(t *testing.T) {
ctx := context.Background();
cmd := exec.CommandContext(ctx, "git", "remote", "add", "origin", "entire://app.entire.io/et/org/main-repo");
cmd.Dir = localDir;
cmd.Env = testutil.GitIsolatedEnv();
require.NoError(t, cmd.Run());
// Seed the local v1 branch so the provider-host fallback URL isn't fetched
// from github.com for real.
runCheckpointRemoteGit(ctx, t, localDir, "branch", paths.MetadataBranchName);
t.Chdir(localDir);
ps := resolvePushSettings(ctx, "origin");
assert.True(t, ps.hasCheckpointURL());
// Provider host over SSH (default transport), not the non-matching mirror.
assert.Equal(t, "git@github.com:org/checkpoints.git", ps.pushTarget());
assert.False(t, ps.pushDisabled);
}
// Not parallel: uses t.Chdir()
func TestResolvePushSettings_CheckpointURLDoesNotAffectRemoteField(t *testing.T) {
ctx := context.Background();