(t *testing.T)
| 519 | } |
| 520 | |
| 521 | func TestExpandShellGlobsUpload(t *testing.T) { |
| 522 | rootCmd := &cobra.Command{Use: "pikpakcli"} |
| 523 | uploadCmd := &cobra.Command{Use: "upload"} |
| 524 | uploadCmd.Flags().StringP("path", "p", "/", "") |
| 525 | uploadCmd.Flags().StringP("parent-id", "P", "", "") |
| 526 | uploadCmd.Flags().Int64P("concurrency", "c", 16, "") |
| 527 | uploadCmd.Flags().StringSliceP("exn", "e", nil, "") |
| 528 | uploadCmd.Flags().BoolP("sync", "s", false, "") |
| 529 | rootCmd.AddCommand(uploadCmd) |
| 530 | |
| 531 | tempDir := t.TempDir() |
| 532 | videoA := filepath.Join(tempDir, "a.mkv") |
| 533 | videoB := filepath.Join(tempDir, "b.mkv") |
| 534 | note := filepath.Join(tempDir, "note.txt") |
| 535 | require.NoError(t, os.WriteFile(videoA, []byte("a"), 0o644)) |
| 536 | require.NoError(t, os.WriteFile(videoB, []byte("b"), 0o644)) |
| 537 | require.NoError(t, os.WriteFile(note, []byte("c"), 0o644)) |
| 538 | |
| 539 | args := adaptShellArgs(rootCmd, "/Movies", []string{"upload", filepath.Join(tempDir, "*.mkv")}) |
| 540 | expanded, err := expandShellGlobs(rootCmd, "/Movies", fakeFileStatProvider{}, args) |
| 541 | require.NoError(t, err) |
| 542 | require.Equal(t, []string{"upload", "-p", "/Movies", videoA, videoB}, expanded) |
| 543 | } |
| 544 | |
| 545 | func TestExpandOpenGlobs(t *testing.T) { |
| 546 | expanded, err := expandOpenGlobs("/Movies", fakeFileStatProvider{ |
nothing calls this directly
no test coverage detected