MCPcopy Create free account
hub / github.com/openclaw/gogcli / TestDownloadDriveFile_HTTPError

Function TestDownloadDriveFile_HTTPError

internal/cmd/drive_download_test.go:167–186  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

165}
166
167func TestDownloadDriveFile_HTTPError(t *testing.T) {
168 download := func(context.Context, *drive.Service, string) (*http.Response, error) {
169 return &http.Response{
170 Status: "403 Forbidden",
171 StatusCode: http.StatusForbidden,
172 Body: io.NopCloser(strings.NewReader("nope\n")),
173 }, nil
174 }
175
176 tmp := t.TempDir()
177 dest := filepath.Join(tmp, "file.bin")
178 ctx := withDriveTestOperations(context.Background(), &drive.Service{}, download, nil)
179 _, _, err := downloadDriveFile(ctx, &drive.Service{}, &drive.File{Id: "id1", MimeType: "application/pdf"}, dest, "", false)
180 if err == nil {
181 t.Fatalf("expected error")
182 }
183 if !strings.Contains(err.Error(), "download failed") || !strings.Contains(err.Error(), "nope") {
184 t.Fatalf("unexpected error: %v", err)
185 }
186}
187
188func TestDownloadDriveFile_CreatesMissingParentDirs(t *testing.T) {
189 download := func(context.Context, *drive.Service, string) (*http.Response, error) {

Callers

nothing calls this directly

Calls 3

withDriveTestOperationsFunction · 0.85
downloadDriveFileFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected