2026-08-27 02:30:32 +00:00
|
|
|
|
package session
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
|
"fmt"
|
|
|
|
|
|
"strings"
|
|
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/Tencent/WeKnora/internal/types"
|
feat(session): fork conversations from a historical user message (#3304)
* feat(session): add fork schema and history queries
为会话分叉增加数据模型与迁移,并提供截至分叉点的消息查询以及会话内的 request_id 配对。
* feat(sandbox): add git, fork snapshots, and bootstrap hook
沙箱镜像安装 git,Docker 快照使用独立的 fork 命名空间,并在首次创建会话沙箱时接入可选 bootstrap。
* feat(session): checkpoint workspace at the end of each turn
每轮结束后对沙箱 /workspace 打 git checkpoint,并避免 fork 后因 mtime 刷新重复挂上产物、以及附件仍绑在父会话而无法还原。
* feat(session): fork conversations and reap orphan snapshots
支持从历史 user 消息分叉会话、首次打开时从快照 bootstrap,并在失败或删除未打开的分叉时回收孤儿快照。
* feat(chat): add session fork entry, prefill, and badges
在用户消息上提供分叉入口,进入新会话时预填原问题,并展示降级提示与来源角标。
* style: add missing newline so session_fork_delete_test.go is gofmt-clean
* fix(session): prune later git history when rolling a fork workspace back
reset --hard 只还原工作区,分叉点之后的 commit 仍可被 checkout。校验 SHA 后丢掉其他 ref 并 gc,避免错误基线。
* style(session): clear golangci-lint findings on the session-fork diff
Pre-push lints the whole PR against main; wrap long lines, check c.Error,
and fix gofumpt/revive/staticcheck so the merge can be pushed.
* fix(chat): show the fork button on hover without shifting the thread
Overlay the action so revealing it no longer expands the user bubble and janks the messages below.
* fix(chat): drop the fork landing banners
Keep the original question prefilled; do not explain sandbox snapshot vs checkpoint on the new thread.
* fix(agent): dedupe artifacts by content hash, not size
Same-path same-size rewrites were skipped as restores. Keep path+mtime as the cheap skip, hash bytes when mtime moves, and stamp the restored mtime onto this session only.
* feat(session): allow forking from an assistant answer
User forks still copy history before the question and prefill it. Assistant forks copy through that reply and reuse its checkpoint, with a degrade tooltip when none exists.
* fix(session): resolve parent attachments from a forked chat
Fork copies attachment IDs onto the new messages but leaves temporary_documents on the parent. Preview and Get now look up those IDs on the fork's copied history instead of a scoped miss.
* fix(agent): rewrite sandbox refs after a content-hash skip
Fork restores change mtime on unchanged files, so Collect returns empty
and named citations were left as sandbox: paths. Resolve those names
against session artifacts, notify only real uploads, and stamp restored
mtime only on the matching content hash.
* fix(session): drop a dead fork snapshot and retry checkpoint rewrite
Create from a missing template now abandons bootstrap so the next
Resolve uses a normal sandbox. A failed checkpoint rewrite no longer
marks the bootstrap consumed, which previously made nested forks
SANDBOX_REPLACED.
* fix(session): load forked parent attachments into the prompt
ResolveForPrompt used session-scoped lookup, so copied parent attachment
IDs passed Get but never reached the model. Use the same resolveInSession
path as preview.
* fix(chat): keep the user-message fork button visible
The control was hover-only, which hid it on touch. Always show it, and
drop the unused degrade tooltip.
---------
Co-authored-by: hailongzhao <hailongzhao@tencent.com>
Co-authored-by: wizardchen <wizardchen@tencent.com>
2026-09-17 06:20:18 +00:00
|
|
|
|
"github.com/stretchr/testify/require"
|
2026-08-27 02:30:32 +00:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// handleFor builds a syntactically valid 22-character resource handle for
|
|
|
|
|
|
// artifact i, so tests exercise the same ParseResourcePath path as production.
|
|
|
|
|
|
func handleFor(i int) string {
|
|
|
|
|
|
base := fmt.Sprintf("art%d", i)
|
|
|
|
|
|
return base + strings.Repeat("x", types.ResourceHandleLength-len(base))
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func refFor(i int) string {
|
|
|
|
|
|
return types.BuildResourcePath(handleFor(i))
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// artifactsFixture builds artifacts whose storage URL is a catalog handle —
|
|
|
|
|
|
// the normal deployment. Use artifactsWithoutCatalog for the degraded case.
|
|
|
|
|
|
func artifactsFixture(names ...string) types.MessageArtifacts {
|
|
|
|
|
|
list := make(types.MessageArtifacts, 0, len(names))
|
|
|
|
|
|
for i, name := range names {
|
|
|
|
|
|
list = append(list, types.MessageArtifact{FileName: name, URL: refFor(i)})
|
|
|
|
|
|
}
|
|
|
|
|
|
return list
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func artifactsWithoutCatalog(names ...string) types.MessageArtifacts {
|
|
|
|
|
|
list := make(types.MessageArtifacts, 0, len(names))
|
|
|
|
|
|
for _, name := range names {
|
|
|
|
|
|
list = append(list, types.MessageArtifact{FileName: name, URL: "local://7/exports/" + name})
|
|
|
|
|
|
}
|
|
|
|
|
|
return list
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func TestRewriteArtifactReferences(t *testing.T) {
|
|
|
|
|
|
artifacts := artifactsFixture(
|
|
|
|
|
|
"市场画像评分_e7edba.html",
|
|
|
|
|
|
"concept_ranking.csv",
|
|
|
|
|
|
"trend.png",
|
|
|
|
|
|
"腾讯控股(00700) 成交量_838ccc.html",
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
cases := []struct {
|
|
|
|
|
|
name string
|
|
|
|
|
|
content string
|
|
|
|
|
|
want string
|
|
|
|
|
|
}{
|
|
|
|
|
|
{
|
|
|
|
|
|
name: "file name with spaces and parentheses",
|
|
|
|
|
|
content: " 成交量_838ccc.html)",
|
|
|
|
|
|
want: " + ")",
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: "file name with spaces and parentheses, no prefix",
|
|
|
|
|
|
content: " 成交量_838ccc.html)",
|
|
|
|
|
|
want: " + ")",
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: "bare file name in image",
|
|
|
|
|
|
content: "",
|
|
|
|
|
|
want: " + ")",
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: "sandbox prefix",
|
|
|
|
|
|
content: "",
|
|
|
|
|
|
want: " + ")",
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: "sandbox scheme with slashes",
|
|
|
|
|
|
content: "",
|
|
|
|
|
|
want: " + ")",
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: "directory prefix is dropped",
|
|
|
|
|
|
content: "[榜单](/workspace/output/concept_ranking.csv)",
|
|
|
|
|
|
want: "[榜单](" + refFor(1) + ")",
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: "percent-encoded name",
|
|
|
|
|
|
content: "",
|
|
|
|
|
|
want: " + ")",
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: "title is preserved",
|
|
|
|
|
|
content: ``,
|
|
|
|
|
|
want: ` + ` "走势")`,
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: "ordinary link with a colliding name is not rewritten",
|
|
|
|
|
|
content: "见 [说明](trend.png)",
|
|
|
|
|
|
want: "见 [说明](trend.png)",
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: "sandbox-prefixed link is rewritten even when not an image",
|
|
|
|
|
|
content: "数据见 [表格](sandbox:concept_ranking.csv)",
|
|
|
|
|
|
want: "数据见 [表格](" + refFor(1) + ")",
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: "already-rewritten reference is left alone",
|
|
|
|
|
|
content: " + ")",
|
|
|
|
|
|
want: " + ")",
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: "prose parentheses are not link destinations",
|
|
|
|
|
|
content: "腾讯控股(00700) 的成交量见下图。",
|
|
|
|
|
|
want: "腾讯控股(00700) 的成交量见下图。",
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: "unknown file name untouched",
|
|
|
|
|
|
content: "",
|
|
|
|
|
|
want: "",
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: "http url untouched",
|
|
|
|
|
|
content: "",
|
|
|
|
|
|
want: "",
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: "knowledge base image untouched",
|
|
|
|
|
|
content: "",
|
|
|
|
|
|
want: "",
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: "fenced code untouched",
|
|
|
|
|
|
content: "```\n\n```",
|
|
|
|
|
|
want: "```\n\n```",
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: "inline code untouched",
|
|
|
|
|
|
content: "写成 `` 即可",
|
|
|
|
|
|
want: "写成 `` 即可",
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: "plain prose untouched",
|
|
|
|
|
|
content: "生成了 trend.png 和 concept_ranking.csv 两个文件。",
|
|
|
|
|
|
want: "生成了 trend.png 和 concept_ranking.csv 两个文件。",
|
|
|
|
|
|
},
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for _, tc := range cases {
|
|
|
|
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
|
|
|
|
if got := rewriteArtifactReferences(tc.content, artifacts); got != tc.want {
|
|
|
|
|
|
t.Fatalf("rewriteArtifactReferences() = %q, want %q", got, tc.want)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func TestRewriteArtifactReferencesMixedContent(t *testing.T) {
|
|
|
|
|
|
artifacts := artifactsFixture("chart.html", "data.csv")
|
|
|
|
|
|
content := "## 图表\n\n\n\n数据见 [表格](sandbox:data.csv)," +
|
|
|
|
|
|
"外链 [文档](https://example.com/chart.html) 不受影响。"
|
|
|
|
|
|
want := "## 图表\n\n + ")\n\n数据见 [表格](" + refFor(1) + ")," +
|
|
|
|
|
|
"外链 [文档](https://example.com/chart.html) 不受影响。"
|
|
|
|
|
|
|
|
|
|
|
|
if got := rewriteArtifactReferences(content, artifacts); got != want {
|
|
|
|
|
|
t.Fatalf("rewriteArtifactReferences() = %q, want %q", got, want)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// A knowledge-base image and a skill artifact routinely appear in the same
|
|
|
|
|
|
// answer. Only the artifact is rebound; the existing reference must survive
|
|
|
|
|
|
// byte for byte, since it already is the canonical form.
|
|
|
|
|
|
func TestRewriteArtifactReferencesKeepsExistingResourceImages(t *testing.T) {
|
|
|
|
|
|
artifacts := artifactsFixture("chart.html")
|
|
|
|
|
|
kbImage := types.BuildResourcePath(strings.Repeat("Z", types.ResourceHandleLength))
|
|
|
|
|
|
content := "\n\n"
|
|
|
|
|
|
want := "\n\n + ")"
|
|
|
|
|
|
|
|
|
|
|
|
if got := rewriteArtifactReferences(content, artifacts); got != want {
|
|
|
|
|
|
t.Fatalf("rewriteArtifactReferences() = %q, want %q", got, want)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Without a resource catalog there is no durable handle, so references are
|
|
|
|
|
|
// normalized to the chat-only sandbox form rather than leaking a storage path.
|
|
|
|
|
|
func TestRewriteArtifactReferencesWithoutCatalog(t *testing.T) {
|
|
|
|
|
|
artifacts := artifactsWithoutCatalog("chart.html")
|
|
|
|
|
|
got := rewriteArtifactReferences("", artifacts)
|
|
|
|
|
|
if want := ""; got != want {
|
|
|
|
|
|
t.Fatalf("rewriteArtifactReferences() = %q, want %q", got, want)
|
|
|
|
|
|
}
|
|
|
|
|
|
if strings.Contains(got, "local://") {
|
|
|
|
|
|
t.Fatalf("storage path leaked into content: %q", got)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func TestRewriteArtifactReferencesNoArtifacts(t *testing.T) {
|
|
|
|
|
|
content := ""
|
|
|
|
|
|
if got := rewriteArtifactReferences(content, nil); got != content {
|
|
|
|
|
|
t.Fatalf("rewriteArtifactReferences() = %q, want unchanged", got)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func TestArtifactRefByNameKeepsFirstDuplicate(t *testing.T) {
|
|
|
|
|
|
byName := artifactRefByName(artifactsFixture("a.html", "a.html", "b.html"))
|
|
|
|
|
|
if byName["a.html"] != refFor(0) {
|
|
|
|
|
|
t.Fatalf("duplicate name resolved to %q, want %q", byName["a.html"], refFor(0))
|
|
|
|
|
|
}
|
|
|
|
|
|
if byName["b.html"] != refFor(2) {
|
|
|
|
|
|
t.Fatalf("b.html resolved to %q, want %q", byName["b.html"], refFor(2))
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
feat(session): fork conversations from a historical user message (#3304)
* feat(session): add fork schema and history queries
为会话分叉增加数据模型与迁移,并提供截至分叉点的消息查询以及会话内的 request_id 配对。
* feat(sandbox): add git, fork snapshots, and bootstrap hook
沙箱镜像安装 git,Docker 快照使用独立的 fork 命名空间,并在首次创建会话沙箱时接入可选 bootstrap。
* feat(session): checkpoint workspace at the end of each turn
每轮结束后对沙箱 /workspace 打 git checkpoint,并避免 fork 后因 mtime 刷新重复挂上产物、以及附件仍绑在父会话而无法还原。
* feat(session): fork conversations and reap orphan snapshots
支持从历史 user 消息分叉会话、首次打开时从快照 bootstrap,并在失败或删除未打开的分叉时回收孤儿快照。
* feat(chat): add session fork entry, prefill, and badges
在用户消息上提供分叉入口,进入新会话时预填原问题,并展示降级提示与来源角标。
* style: add missing newline so session_fork_delete_test.go is gofmt-clean
* fix(session): prune later git history when rolling a fork workspace back
reset --hard 只还原工作区,分叉点之后的 commit 仍可被 checkout。校验 SHA 后丢掉其他 ref 并 gc,避免错误基线。
* style(session): clear golangci-lint findings on the session-fork diff
Pre-push lints the whole PR against main; wrap long lines, check c.Error,
and fix gofumpt/revive/staticcheck so the merge can be pushed.
* fix(chat): show the fork button on hover without shifting the thread
Overlay the action so revealing it no longer expands the user bubble and janks the messages below.
* fix(chat): drop the fork landing banners
Keep the original question prefilled; do not explain sandbox snapshot vs checkpoint on the new thread.
* fix(agent): dedupe artifacts by content hash, not size
Same-path same-size rewrites were skipped as restores. Keep path+mtime as the cheap skip, hash bytes when mtime moves, and stamp the restored mtime onto this session only.
* feat(session): allow forking from an assistant answer
User forks still copy history before the question and prefill it. Assistant forks copy through that reply and reuse its checkpoint, with a degrade tooltip when none exists.
* fix(session): resolve parent attachments from a forked chat
Fork copies attachment IDs onto the new messages but leaves temporary_documents on the parent. Preview and Get now look up those IDs on the fork's copied history instead of a scoped miss.
* fix(agent): rewrite sandbox refs after a content-hash skip
Fork restores change mtime on unchanged files, so Collect returns empty
and named citations were left as sandbox: paths. Resolve those names
against session artifacts, notify only real uploads, and stamp restored
mtime only on the matching content hash.
* fix(session): drop a dead fork snapshot and retry checkpoint rewrite
Create from a missing template now abandons bootstrap so the next
Resolve uses a normal sandbox. A failed checkpoint rewrite no longer
marks the bootstrap consumed, which previously made nested forks
SANDBOX_REPLACED.
* fix(session): load forked parent attachments into the prompt
ResolveForPrompt used session-scoped lookup, so copied parent attachment
IDs passed Get but never reached the model. Use the same resolveInSession
path as preview.
* fix(chat): keep the user-message fork button visible
The control was hover-only, which hid it on touch. Always show it, and
drop the unused degrade tooltip.
---------
Co-authored-by: hailongzhao <hailongzhao@tencent.com>
Co-authored-by: wizardchen <wizardchen@tencent.com>
2026-09-17 06:20:18 +00:00
|
|
|
|
|
|
|
|
|
|
func TestReferencedArtifactsMatchesNamesAndHandles(t *testing.T) {
|
|
|
|
|
|
artifacts := artifactsFixture("report.pptx", "chart.html", "data.csv")
|
|
|
|
|
|
|
|
|
|
|
|
cases := []struct {
|
|
|
|
|
|
name string
|
|
|
|
|
|
content string
|
|
|
|
|
|
want types.MessageArtifacts
|
|
|
|
|
|
}{
|
|
|
|
|
|
{
|
|
|
|
|
|
name: "sandbox-prefixed name",
|
|
|
|
|
|
content: "已生成 ",
|
|
|
|
|
|
want: types.MessageArtifacts{artifacts[0]},
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: "bare name in an image",
|
|
|
|
|
|
content: "",
|
|
|
|
|
|
want: types.MessageArtifacts{artifacts[1]},
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: "output path in an ordinary link",
|
|
|
|
|
|
content: "[数据](./output/data.csv)",
|
|
|
|
|
|
want: types.MessageArtifacts{artifacts[2]},
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: "canonical handle",
|
|
|
|
|
|
content: " + ")",
|
|
|
|
|
|
want: types.MessageArtifacts{artifacts[0]},
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: "prose mention is not a reference",
|
|
|
|
|
|
content: "生成了 report.pptx 和 chart.html 两个文件。",
|
|
|
|
|
|
want: nil,
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: "bare name in an ordinary link is not a reference",
|
|
|
|
|
|
content: "见 [说明](report.pptx)",
|
|
|
|
|
|
want: nil,
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: "unknown name",
|
|
|
|
|
|
content: "",
|
|
|
|
|
|
want: nil,
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: "code sample is not a reference",
|
|
|
|
|
|
content: "```\n\n```",
|
|
|
|
|
|
want: nil,
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
// Go regexp.Split does not interleave the matched fences, so
|
|
|
|
|
|
// walking parts with i+=2 would skip the segment after the first
|
|
|
|
|
|
// fence and miss a real citation that rewrite still rewrites.
|
|
|
|
|
|
name: "reference after a code fence",
|
|
|
|
|
|
content: "\n\n```\n\n```\n\n",
|
|
|
|
|
|
want: types.MessageArtifacts{artifacts[0], artifacts[1]},
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: "multiple references keep candidate order",
|
|
|
|
|
|
content: "\n\n",
|
|
|
|
|
|
want: types.MessageArtifacts{artifacts[0], artifacts[2]},
|
|
|
|
|
|
},
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for _, tc := range cases {
|
|
|
|
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
|
|
|
|
require.Equal(t, tc.want, referencedArtifacts(tc.content, artifacts))
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// A regenerated file shadows the older version of itself: the name resolves to
|
|
|
|
|
|
// the first candidate, while an explicit handle still reaches the old one.
|
|
|
|
|
|
func TestReferencedArtifactsPrefersTheFirstCandidate(t *testing.T) {
|
|
|
|
|
|
old := types.MessageArtifact{FileName: "deck.pptx", URL: refFor(0)}
|
|
|
|
|
|
fresh := types.MessageArtifact{FileName: "deck.pptx", URL: refFor(1)}
|
|
|
|
|
|
candidates := types.MessageArtifacts{fresh, old}
|
|
|
|
|
|
|
|
|
|
|
|
require.Equal(t, types.MessageArtifacts{fresh},
|
|
|
|
|
|
referencedArtifacts("", candidates))
|
|
|
|
|
|
require.Equal(t, types.MessageArtifacts{old},
|
|
|
|
|
|
referencedArtifacts("", candidates))
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// KnownArtifacts is oldest-first. Reverse it before merging so a hash-skipped
|
|
|
|
|
|
// name binds the latest file; this turn still shadows that latest file.
|
|
|
|
|
|
func TestMergeArtifactListsPrefersThisTurnThenLatestKnown(t *testing.T) {
|
|
|
|
|
|
old := types.MessageArtifact{FileName: "deck.pptx", URL: refFor(0)}
|
|
|
|
|
|
latest := types.MessageArtifact{FileName: "deck.pptx", URL: refFor(1)}
|
|
|
|
|
|
fresh := types.MessageArtifact{FileName: "deck.pptx", URL: refFor(2)}
|
|
|
|
|
|
known := types.MessageArtifacts{old, latest}
|
|
|
|
|
|
|
|
|
|
|
|
require.Equal(t, types.MessageArtifacts{latest},
|
|
|
|
|
|
referencedArtifacts("",
|
|
|
|
|
|
mergeArtifactLists(nil, artifactsNewestFirst(known))))
|
|
|
|
|
|
require.Equal(t, types.MessageArtifacts{fresh},
|
|
|
|
|
|
referencedArtifacts("",
|
|
|
|
|
|
mergeArtifactLists(types.MessageArtifacts{fresh}, artifactsNewestFirst(known))))
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func TestArtifactsNewestFirstDoesNotMutateInput(t *testing.T) {
|
|
|
|
|
|
in := artifactsFixture("a.html", "b.html")
|
|
|
|
|
|
got := artifactsNewestFirst(in)
|
|
|
|
|
|
require.Equal(t, "b.html", got[0].FileName)
|
|
|
|
|
|
require.Equal(t, "a.html", got[1].FileName)
|
|
|
|
|
|
require.Equal(t, "a.html", in[0].FileName)
|
|
|
|
|
|
}
|