test(seam): make testseam the only seam-swap form and legislate it
- Add testseam.Protect for save-and-restore seams with no up-front stub value (e.g. os.Args mutated by the code under test). - Migrate all 35 remaining manual prev/assign/t.Cleanup-restore trios to testseam.Swap/Protect across app, auth, cli, event, helpers, output, pipeline, and shortcut tests; restores can no longer be forgotten. - check-schema-catalog.sh: fail closed when a manual seam restore reappears in any *_test.go (internal/testseam exempt). Seam injection is now a mechanism, not a convention.
This commit is contained in:
1 parent
e5a47a2d18
commit
0fbdfe0130
30 files changed
+183
-90
No files matched your search
@@ -19,11 +19,12 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/DingTalk-Real-AI/dingtalk-workspace-cli/internal/testseam"
|
||||
)
|
||||
|
||||
func TestPrepareOpenCodeAttachmentsUsesStoryboardAndTranscript(t *testing.T) {
|
||||
previous := generateConnectVideoStoryboard
|
||||
t.Cleanup(func() { generateConnectVideoStoryboard = previous })
|
||||
testseam.Protect(t, &generateConnectVideoStoryboard)
|
||||
storyboard := filepath.Join(t.TempDir(), "storyboard.jpg")
|
||||
if err := os.WriteFile(storyboard, []byte("jpeg"), 0o600); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -61,11 +62,9 @@ func TestPrepareOpenCodeAttachmentsUsesStoryboardAndTranscript(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPrepareOpenCodeAttachmentsDoesNotSubmitVideoWhenStoryboardFails(t *testing.T) {
|
||||
previous := generateConnectVideoStoryboard
|
||||
t.Cleanup(func() { generateConnectVideoStoryboard = previous })
|
||||
generateConnectVideoStoryboard = func(context.Context, string) (string, error) {
|
||||
testseam.Swap(t, &generateConnectVideoStoryboard, func(context.Context, string) (string, error) {
|
||||
return "", os.ErrNotExist
|
||||
}
|
||||
})
|
||||
prompt, attachments := prepareOpenCodeAttachments(context.Background(), "请看视频", []connectMediaAttachment{
|
||||
{LocalPath: "/tmp/original.mov", FileName: "demo.mov", MediaType: "video"},
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user