Skip to content

Commit 7d977a2

Browse files
committed
test message
1 parent add1006 commit 7d977a2

2 files changed

Lines changed: 39 additions & 16 deletions

File tree

internal/ui/selector/selector_history_test.go

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -205,28 +205,35 @@ func TestFilterHistoryEntries_NoMatch(t *testing.T) {
205205
}
206206

207207
// ---------------------------------------------------------------------------
208-
// InitHistory
208+
// InitHistory / file round-trip
209209
// ---------------------------------------------------------------------------
210210

211-
func TestInitHistory_LoadsFromFile(t *testing.T) {
211+
// TestHistoryFileRoundTrip verifies that entries written by appendHistory
212+
// are correctly persisted to the file and can be reloaded into memory.
213+
// (InitHistory always uses ~/.iterate/history so we test the persistence
214+
// path directly rather than calling InitHistory with a temp path.)
215+
func TestHistoryFileRoundTrip(t *testing.T) {
212216
resetHistory()
213217
dir := t.TempDir()
214-
histFile := filepath.Join(dir, "history")
215-
os.WriteFile(histFile, []byte("cmd1\ncmd2\ncmd3\n"), 0o600)
218+
historyFile = filepath.Join(dir, "history")
216219

217-
// Point historyFile at the temp file, then call the real loader.
218-
historyFile = histFile
219-
InitHistory()
220+
appendHistory("cmd1")
221+
appendHistory("cmd2")
222+
appendHistory("cmd3")
220223

221-
h := getInputHistory()
222-
// InitHistory appends to existing; we reset first so count is exact.
223-
var found []string
224-
for _, v := range h {
225-
if v == "cmd1" || v == "cmd2" || v == "cmd3" {
226-
found = append(found, v)
227-
}
224+
// Verify the file was written
225+
data, err := os.ReadFile(historyFile)
226+
if err != nil {
227+
t.Fatalf("history file not created: %v", err)
228+
}
229+
lines := strings.Split(strings.TrimRight(string(data), "\n"), "\n")
230+
if len(lines) != 3 || lines[0] != "cmd1" || lines[2] != "cmd3" {
231+
t.Errorf("file contents unexpected: %v", lines)
228232
}
229-
if len(found) != 3 {
230-
t.Errorf("expected cmd1/cmd2/cmd3 in history, got %v", h)
233+
234+
// Verify in-memory state matches
235+
h := getInputHistory()
236+
if len(h) != 3 || h[0] != "cmd1" || h[2] != "cmd3" {
237+
t.Errorf("in-memory history unexpected: %v", h)
231238
}
232239
}

scripts/evolution/evolve.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@ BRANCH="evolution/day-${DAY}"
185185
# ── Final commit and push ──
186186
log "Pushing changes..."
187187
<<<<<<< Updated upstream
188+
<<<<<<< Updated upstream
189+
>>>>>>> Stashed changes
190+
=======
188191
>>>>>>> Stashed changes
189192
=======
190193
>>>>>>> Stashed changes
@@ -193,13 +196,16 @@ log "Pushing changes..."
193196
DAY=$(( ($(date -u +%s) - $(date -d "$BIRTH_DATE" +%s 2>/dev/null || date -j -f "%Y-%m-%d" "$BIRTH_DATE" +%s)) / 86400 ))
194197
echo "$DAY" > "${REPOPATH}/DAY_COUNT"
195198

199+
<<<<<<< Updated upstream
196200
<<<<<<< Updated upstream
197201
<<<<<<< Updated upstream
198202
# Stage and commit all changes
199203
=======
200204
>>>>>>> Stashed changes
201205
=======
202206
>>>>>>> Stashed changes
207+
=======
208+
>>>>>>> Stashed changes
203209
if [[ -n $(git status -s) ]]; then
204210
git add -A
205211
git commit -m "iterate: Day $DAY evolution session" 2>/dev/null || true
@@ -208,6 +214,8 @@ fi
208214
=======
209215
git pull --rebase origin main 2>/dev/null || true
210216
<<<<<<< Updated upstream
217+
<<<<<<< Updated upstream
218+
=======
211219
=======
212220

213221
# Always ensure DAY_COUNT is correct after pull
@@ -226,6 +234,14 @@ git commit --amend --no-edit 2>/dev/null || git commit -m "iterate: Day $DAY evo
226234
git push origin main 2>/dev/null || log "Push failed"
227235
>>>>>>> Stashed changes
228236

237+
# Always ensure DAY_COUNT is correct after pull
238+
echo "$DAY" > "${REPOPATH}/DAY_COUNT"
239+
git add DAY_COUNT 2>/dev/null || true
240+
git commit --amend --no-edit 2>/dev/null || git commit -m "iterate: Day $DAY evolution session" 2>/dev/null || true
241+
242+
git push origin main 2>/dev/null || log "Push failed"
243+
>>>>>>> Stashed changes
244+
229245
# Pull latest main
230246
git pull --rebase origin main 2>/dev/null || true
231247

0 commit comments

Comments
 (0)