MCPcopy Create free account
hub / github.com/52funny/pikpakcli / TestRunCreatesConfig

Function TestRunCreatesConfig

cli/setup/setup_test.go:40–67  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

38}
39
40func TestRunCreatesConfig(t *testing.T) {
41 targetPath := filepath.Join(t.TempDir(), "pikpakcli", "config.yml")
42
43 path, err := Run(Options{
44 TargetPath: targetPath,
45 Prompts: &fakePrompts{
46 lines: []string{"user@example.com", "http://127.0.0.1:7890", "~/Downloads/pikpak-open"},
47 password: "secret",
48 },
49 })
50 require.NoError(t, err)
51 assert.Equal(t, targetPath, path)
52
53 bs, err := os.ReadFile(targetPath)
54 require.NoError(t, err)
55
56 var cfg map[string]any
57 require.NoError(t, yaml.Unmarshal(bs, &cfg))
58 assert.Equal(t, "http://127.0.0.1:7890", cfg["proxy"])
59 assert.Equal(t, "user@example.com", cfg["username"])
60 assert.Equal(t, "secret", cfg["password"])
61
62 openCfg, ok := cfg["open"].(map[string]any)
63 require.True(t, ok)
64 assert.Equal(t, "~/Downloads/pikpak-open", openCfg["download_dir"])
65 assert.Equal(t, []any{}, openCfg["default"])
66 assert.Contains(t, string(bs), "# PikPak account username")
67}
68
69func TestRunRejectsExistingConfigWithoutForce(t *testing.T) {
70 targetPath := filepath.Join(t.TempDir(), "config.yml")

Callers

nothing calls this directly

Calls 1

RunFunction · 0.85

Tested by

no test coverage detected