Skip to content

Commit 355739e

Browse files
committed
fix libs tests
1 parent 7fdc4e9 commit 355739e

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

libs/backendapi/diggerapi.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ func (d DiggerApi) ReportProjectJobStatus(repo string, projectName string, jobId
189189

190190
body, err := io.ReadAll(resp.Body)
191191
if err != nil {
192-
return nil, fmt.Errorf("Could not read response body: %v", err)
192+
return nil, fmt.Errorf("could not read response body: %v", err)
193193
}
194194

195195
var response scheduler.SerializedBatch
@@ -204,14 +204,14 @@ func (d DiggerApi) UploadJobArtefact(zipLocation string) (*int, *string, error)
204204
return nil, nil, err
205205
}
206206
u.Path = path.Join(u.Path, "job_artefacts")
207-
url := u.String()
207+
uploadUrl := u.String()
208208
filePath := zipLocation
209209

210210
// Open the file
211211
file, err := os.Open(filePath)
212212
if err != nil {
213-
fmt.Println("Error opening file:", err)
214-
return nil, nil, fmt.Errorf("Error opening file:", err)
213+
fmt.Println("error opening file:", err)
214+
return nil, nil, fmt.Errorf("error opening file: %v", err)
215215
}
216216
defer file.Close()
217217

@@ -225,24 +225,24 @@ func (d DiggerApi) UploadJobArtefact(zipLocation string) (*int, *string, error)
225225
fileWriter, err := multipartWriter.CreateFormFile("file", filepath.Base(filePath))
226226
if err != nil {
227227
fmt.Println("Error creating form file:", err)
228-
return nil, nil, fmt.Errorf("Error creating form file:", err)
228+
return nil, nil, fmt.Errorf("error creating form file: %v", err)
229229
}
230230

231231
// Copy the file content to the form file writer
232232
_, err = io.Copy(fileWriter, file)
233233
if err != nil {
234234
fmt.Println("Error copying file content:", err)
235-
return nil, nil, fmt.Errorf("Error copying file content:", err)
235+
return nil, nil, fmt.Errorf("error copying file content: %v", err)
236236
}
237237

238238
// Close the multipart writer to finalize the request body
239239
multipartWriter.Close()
240240

241241
// Create a new HTTP request
242-
req, err := http.NewRequest("PUT", url, &requestBody)
242+
req, err := http.NewRequest("PUT", uploadUrl, &requestBody)
243243
if err != nil {
244244
fmt.Println("Error creating request:", err)
245-
return nil, nil, fmt.Errorf("Error creating request:", err)
245+
return nil, nil, fmt.Errorf("error creating request: %v", err)
246246
}
247247

248248
// Set the content type header
@@ -254,15 +254,15 @@ func (d DiggerApi) UploadJobArtefact(zipLocation string) (*int, *string, error)
254254
resp, err := client.Do(req)
255255
if err != nil {
256256
fmt.Println("Error sending request:", err)
257-
return nil, nil, fmt.Errorf("Error sending request:", err)
257+
return nil, nil, fmt.Errorf("error sending request: %v", err)
258258
}
259259
defer resp.Body.Close()
260260

261261
// Read and print the response
262262
body, err := io.ReadAll(resp.Body)
263263
if err != nil {
264264
fmt.Println("Error reading response:", err)
265-
return nil, nil, fmt.Errorf("Error reading response: %v", err)
265+
return nil, nil, fmt.Errorf("error reading response: %v", err)
266266
}
267267

268268
b := string(body)
@@ -284,17 +284,17 @@ func getFilename(resp *http.Response) string {
284284

285285
func (d DiggerApi) DownloadJobArtefact(downloadTo string) (*string, error) {
286286
// Download the zip file
287-
url, err := url.JoinPath(d.DiggerHost, "job_artefacts")
287+
downloadUrl, err := url.JoinPath(d.DiggerHost, "job_artefacts")
288288
if err != nil {
289289
log.Printf("failed to create url: %v", err)
290290
return nil, err
291291
}
292292

293293
// Create a new HTTP request
294-
req, err := http.NewRequest("GET", url, nil)
294+
req, err := http.NewRequest("GET", downloadUrl, nil)
295295
if err != nil {
296296
fmt.Println("Error creating request:", err)
297-
return nil, fmt.Errorf("Error creating request:", err)
297+
return nil, fmt.Errorf("error creating request: %v", err)
298298
}
299299

300300
// Set the content type header

0 commit comments

Comments
 (0)