feat(git): per-key cache invalidation and optional submodule tracking
This commit is contained in:
@@ -325,3 +325,63 @@ t.test("Status:aggregate_at with prefix '.' includes everything", function()
|
||||
}))
|
||||
t.eq(#s:aggregate_at("."), 2)
|
||||
end)
|
||||
|
||||
t.test("entry_equal: identical changed entries", function()
|
||||
local a = { kind = "changed", path = "x", staged = "modified" }
|
||||
local b = { kind = "changed", path = "x", staged = "modified" }
|
||||
t.truthy(status.entry_equal(a, b))
|
||||
end)
|
||||
|
||||
t.test("entry_equal: differing staged side returns false", function()
|
||||
local a = { kind = "changed", path = "x", staged = "modified" }
|
||||
local b = { kind = "changed", path = "x", staged = "added" }
|
||||
t.falsy(status.entry_equal(a, b))
|
||||
end)
|
||||
|
||||
t.test("entry_equal: differing orig returns false", function()
|
||||
local a = { kind = "changed", path = "x", staged = "renamed", orig = "y" }
|
||||
local b = { kind = "changed", path = "x", staged = "renamed", orig = "z" }
|
||||
t.falsy(status.entry_equal(a, b))
|
||||
end)
|
||||
|
||||
t.test("entry_equal: nil vs nil is true", function()
|
||||
t.truthy(status.entry_equal(nil, nil))
|
||||
end)
|
||||
|
||||
t.test("entry_equal: nil vs entry is false", function()
|
||||
t.falsy(status.entry_equal(nil, { kind = "untracked", path = "x" }))
|
||||
end)
|
||||
|
||||
t.test("entry_equal: different kinds returns false", function()
|
||||
local a = { kind = "untracked", path = "x" }
|
||||
local b = { kind = "ignored", path = "x" }
|
||||
t.falsy(status.entry_equal(a, b))
|
||||
end)
|
||||
|
||||
t.test("entry_equal: differing unmerged conflict returns false", function()
|
||||
local a = { kind = "unmerged", path = "x", conflict = "both_added" }
|
||||
local b = { kind = "unmerged", path = "x", conflict = "both_modified" }
|
||||
t.falsy(status.entry_equal(a, b))
|
||||
end)
|
||||
|
||||
t.test("diff_entries: detects additions, removals, and modifications", function()
|
||||
local prior = {
|
||||
a = { kind = "changed", path = "a", staged = "modified" },
|
||||
b = { kind = "untracked", path = "b" },
|
||||
}
|
||||
local next_ = {
|
||||
a = { kind = "changed", path = "a", staged = "added" },
|
||||
c = { kind = "untracked", path = "c" },
|
||||
}
|
||||
local changed = status.diff_entries(prior, next_)
|
||||
t.truthy(changed.a, "a modified")
|
||||
t.truthy(changed.b, "b removed")
|
||||
t.truthy(changed.c, "c added")
|
||||
end)
|
||||
|
||||
t.test("diff_entries: empty when entries match", function()
|
||||
local prior = { a = { kind = "untracked", path = "a" } }
|
||||
local next_ = { a = { kind = "untracked", path = "a" } }
|
||||
t.eq(status.diff_entries(prior, next_), {})
|
||||
end)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user