test: harden backend ref helpers per review · Entire

test: harden backend ref helpers per review

7a45cf4·

Soph·1w ago·2 files·+10 added/-14 removed

Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

Sessions

08fd76379af0View transcript

Changes

2

130 unmodified lines

131
132
133
134
134
135
136
137
138
139
140
141

130 unmodified lines

cmd.Env = testutil.GitIsolatedEnv()
    out, err := cmd.Output()
    if err != nil {
        return false
        // Fail rather than return false: a broken invocation reported as
        // "no refs" would make a "should NOT exist" assertion pass vacuously
        // (same reasoning as RemoteCheckpointState). An absent prefix is not
        // an error — for-each-ref exits 0 with empty output.
        t.Fatalf("anyRefUnderPrefix: git for-each-ref %s in %s failed: %v", prefix, dir, err)
    }
    return strings.TrimSpace(string(out)) != ""
}

Mcmd/entire/cli/integration_test/backend.go+5/-1

5 unmodified lines

6
7
8
9
10
11
12
13
25 unmodified lines

39
40
41
40
41
42
43
44
45
46
47
48
49
42
51
52
53
43
44
45
46
47
48

5 unmodified lines

"os"
    "sort"
    "strings"

"github.com/entireio/cli/cmd/entire/cli/checkpoint/id"

// Checkpoint storage backends the e2e suite can run against. Selected per-run by
25 unmodified lines

// guard on this to skip under git-refs.
func UsingGitRefs() bool { return checkpointStoreMode() == storeModeGitRefs }

// checkpointShard returns the two-char ref shard for a checkpoint ID, matching
// cmd/entire/cli/checkpoint/id.ShardFor: the last two chars, for both legacy
// 12-hex IDs and 26-char ULIDs.
func checkpointShard(id string) string {
    if len(id) < 2 {
        return id
    }
    return id[len(id)-2:]
}

// checkpointRefName returns refs/entire/checkpoints/<shard>/<id> for the git-refs
// store.
func checkpointRefName(id string) string {
    return checkpointRefPrefix + checkpointShard(id) + "/" + id
// store, using the production shard computation (id.ShardFor).
func checkpointRefName(checkpointID string) string {
    return checkpointRefPrefix + id.CheckpointID(checkpointID).ShardFor() + "/" + checkpointID
}

// checkpointBlobSpec returns the `git show` spec (ref:path) for a path relative