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

Function TestExpandShellGlobsUpload

internal/shell/shell_test.go:521–543  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

519}
520
521func 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
545func TestExpandOpenGlobs(t *testing.T) {
546 expanded, err := expandOpenGlobs("/Movies", fakeFileStatProvider{

Callers

nothing calls this directly

Calls 2

adaptShellArgsFunction · 0.85
expandShellGlobsFunction · 0.85

Tested by

no test coverage detected