test(source-links): align group test and raw-write ratchet with the review fixes

uninstall --group on a followed link is now refused, and restore no
longer creates parents with a raw MkdirAll, so the ratchet allowance
for it is stale.
This commit is contained in:
Willie
2026-10-05 15:50:00 +08:00
parent bcf567f80d
commit 2b76402240
2 changed files with 12 additions and 16 deletions
+7 -10
View File
@@ -3,6 +3,7 @@ package main
import (
"os"
"path/filepath"
"strings"
"testing"
"skillshare/internal/sourcewalk"
@@ -22,12 +23,13 @@ func TestGroupFollowedLogicalPaths(t *testing.T) {
if err != nil {
t.Fatal(err)
}
removals, err := resolveGroupSkills("_dev-skills", source, walk)
if err != nil {
t.Fatal(err)
// uninstall --group on the link would empty the user's checkout, so it is
// refused in favor of `uninstall _dev-skills` or naming the skills.
if _, err := resolveGroupSkills("_dev-skills", source, walk); err == nil || !strings.Contains(err.Error(), "followed source link") {
t.Fatalf("uninstall --group on a followed link: %v", err)
}
if len(updates) != 2 || len(removals) != 2 {
t.Fatalf("updates=%+v removals=%+v", updates, removals)
if len(updates) != 2 {
t.Fatalf("updates=%+v", updates)
}
for _, target := range updates {
if target.path != filepath.Join(source, target.name) {
@@ -37,11 +39,6 @@ func TestGroupFollowedLogicalPaths(t *testing.T) {
t.Errorf("metadata identity lost: %+v", target)
}
}
for _, target := range removals {
if target.path != filepath.Join(source, target.name) {
t.Errorf("nonlogical uninstall: %+v", target)
}
}
if _, err := resolveGroupUpdatable("_dev-skills", source); err == nil {
t.Error("disabled update accepted external group")
}
+5 -6
View File
@@ -478,11 +478,7 @@ internal/trash/trash.go MoveAgentToTrash os.Rename agentFile, destFile agents
internal/trash/trash.go MoveAgentToTrash os.Rename metaFile, destMeta agents
internal/trash/trash.go MoveAgentToTrash os.WriteFile destFile trash
internal/trash/trash.go MoveAgentToTrash os.WriteFile destMeta trash
internal/trash/trash.go moveToTrash os.MkdirAll filepath.Dir(trashPath) trash
internal/trash/trash.go moveToTrash os.RemoveAll srcPath source-checked
internal/trash/trash.go MoveToTrash os.Rename <ref> source-checked
internal/trash/trash.go restore os.MkdirAll filepath.Dir(destPath) source-unmigrated
internal/trash/trash.go restore os.RemoveAll entry.Path trash
internal/trash/trash.go Restore os.Rename <ref> source-unmigrated
internal/trash/trash.go RestoreAgent os.MkdirAll targetDir agents
internal/trash/trash.go RestoreAgent os.RemoveAll entry.Path trash
@@ -491,9 +487,12 @@ internal/trash/trash.go RestoreAgent os.WriteFile destPath agents
internal/trash/trash.go cleanEmptyParents os.Remove dir trash
internal/trash/trash.go copyDir os.MkdirAll dst source-unmigrated
internal/trash/trash.go copyFile os.OpenFile dst source-unmigrated
internal/trash/trash.go moveLink os.Symlink target, dst source-unmigrated
internal/trash/trash.go moveLink os.Remove src source-checked
internal/trash/trash.go moveLink os.Remove dst source-unmigrated
internal/trash/trash.go moveLink os.Remove src source-checked
internal/trash/trash.go moveLink os.Symlink target, dst source-unmigrated
internal/trash/trash.go moveToTrash os.MkdirAll filepath.Dir(trashPath) trash
internal/trash/trash.go moveToTrash os.RemoveAll srcPath source-checked
internal/trash/trash.go restore os.RemoveAll entry.Path trash
internal/uidist/uidist.go ClearCache os.RemoveAll dir config
internal/uidist/uidist.go ClearVersion os.RemoveAll dir config
internal/uidist/uidist.go Download os.MkdirAll dir config
Can't render this file because it contains an unexpected character in line 23 and column 89.