(t *testing.T)
| 106 | } |
| 107 | |
| 108 | func TestGetDstDefaultsToBasename(t *testing.T) { |
| 109 | tmpDir := t.TempDir() |
| 110 | origDir, _ := os.Getwd() |
| 111 | _ = os.Chdir(tmpDir) |
| 112 | defer func() { _ = os.Chdir(origDir) }() |
| 113 | |
| 114 | content := "downloaded content" |
| 115 | mock := &mockFilesClient{ |
| 116 | downloadFn: func(arg *files.DownloadArg) (*files.FileMetadata, io.ReadCloser, error) { |
| 117 | if arg.Path != "/some/path/file.txt" { |
| 118 | t.Errorf("download path = %q, want %q", arg.Path, "/some/path/file.txt") |
| 119 | } |
| 120 | meta := &files.FileMetadata{ |
| 121 | Metadata: files.Metadata{PathDisplay: "/some/path/file.txt"}, |
| 122 | Size: uint64(len(content)), |
| 123 | } |
| 124 | return meta, io.NopCloser(strings.NewReader(content)), nil |
| 125 | }, |
| 126 | } |
| 127 | |
| 128 | err := getWithClient(mock, []string{"/some/path/file.txt"}) |
| 129 | if err != nil { |
| 130 | t.Fatalf("expected nil error, got %v", err) |
| 131 | } |
| 132 | got, err := os.ReadFile(filepath.Join(tmpDir, "file.txt")) |
| 133 | if err != nil { |
| 134 | t.Fatalf("failed to read downloaded file: %v", err) |
| 135 | } |
| 136 | if string(got) != content { |
| 137 | t.Errorf("got %q, want %q", string(got), content) |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | func TestGetDstAppendsToDirectory(t *testing.T) { |
| 142 | tmpDir := t.TempDir() |
nothing calls this directly
no test coverage detected