chore: 适配 macOS 编译(测试期望改用平台路径分隔符、统一 LF 行尾)
This commit is contained in:
@@ -2,6 +2,7 @@ package core
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
@@ -31,23 +32,25 @@ func TestBuildDir(t *testing.T) {
|
||||
want string
|
||||
}{
|
||||
{"{title}", "[Noxe] 0820 Qingxiao [AI Generated]"},
|
||||
{"{artist}/{title}", `Noxe\[Noxe] 0820 Qingxiao [AI Generated]`},
|
||||
{"{group}/{title}", `CriticalHAI\[Noxe] 0820 Qingxiao [AI Generated]`},
|
||||
{"{category}/{group}/{title}", `misc\CriticalHAI\[Noxe] 0820 Qingxiao [AI Generated]`},
|
||||
{"{tags:2}/{artist}/{title}", `qingxiao_rover\Noxe\[Noxe] 0820 Qingxiao [AI Generated]`},
|
||||
{"{tags}/{artist}/{title}", `qingxiao_rover_big breasts_x-ray_ai generated\Noxe\[Noxe] 0820 Qingxiao [AI Generated]`},
|
||||
{"{artist}/{title}", `Noxe/[Noxe] 0820 Qingxiao [AI Generated]`},
|
||||
{"{group}/{title}", `CriticalHAI/[Noxe] 0820 Qingxiao [AI Generated]`},
|
||||
{"{category}/{group}/{title}", `misc/CriticalHAI/[Noxe] 0820 Qingxiao [AI Generated]`},
|
||||
{"{tags:2}/{artist}/{title}", `qingxiao_rover/Noxe/[Noxe] 0820 Qingxiao [AI Generated]`},
|
||||
{"{tags}/{artist}/{title}", `qingxiao_rover_big breasts_x-ray_ai generated/Noxe/[Noxe] 0820 Qingxiao [AI Generated]`},
|
||||
{"{tag1}-{tag2}", "qingxiao-rover"},
|
||||
{"{artist} - {gid} - {title}", "Noxe - 4239274 - [Noxe] 0820 Qingxiao [AI Generated]"},
|
||||
{"{gid}", "4239274"},
|
||||
{"{lang}/{title}", `chinese\[Noxe] 0820 Qingxiao [AI Generated]`},
|
||||
{"{unknown}/{title}", `{unknown}\[Noxe] 0820 Qingxiao [AI Generated]`}, // 未知占位符原样保留
|
||||
{"{lang}/{title}", `chinese/[Noxe] 0820 Qingxiao [AI Generated]`},
|
||||
{"{unknown}/{title}", `{unknown}/[Noxe] 0820 Qingxiao [AI Generated]`}, // 未知占位符原样保留
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.tpl, func(t *testing.T) {
|
||||
got := BuildDir(tt.tpl, g)
|
||||
if got != tt.want {
|
||||
t.Errorf("\n got: %q\nwant: %q", got, tt.want)
|
||||
// 期望值用 / 书写,再换成本机路径分隔符(Windows 是 \)
|
||||
want := strings.ReplaceAll(tt.want, "/", string(filepath.Separator))
|
||||
if got != want {
|
||||
t.Errorf("\n got: %q\nwant: %q", got, want)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user