Skip to content

Commit 4560352

Browse files
author
gferraro
committed
rename function to be upload video
1 parent 9be8172 commit 4560352

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

api.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,8 @@ func shaHash(r io.Reader) (string, error) {
290290
return hashString, nil
291291
}
292292

293-
// UploadThermalRaw uploads the file to Cacophony API as a multipartmessage
294-
// with data of type thermalRaw specified
295-
func (api *CacophonyAPI) UploadThermalRaw(r io.Reader, data map[string]interface{}) (int, error) {
293+
// UploadVideo uploads the file to Cacophony API as a multipartmessage
294+
func (api *CacophonyAPI) UploadVideo(r io.Reader, data map[string]interface{}) (int, error) {
296295
buf := new(bytes.Buffer)
297296
w := multipart.NewWriter(buf)
298297
//This will write to fileBytes as it reads r to get the sha hash

api_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,13 @@ func TestNewTokenHttpRequest(t *testing.T) {
8989
assert.NoError(t, err)
9090
}
9191

92-
func TestUploadThermalRawHttpRequest(t *testing.T) {
93-
ts := GetUploadThermalRawServer(t)
92+
func TestUploadVideoHttpRequest(t *testing.T) {
93+
ts := GetUploadVideoServer(t)
9494
defer ts.Close()
9595

9696
api := getAPI(ts.URL, "", true)
9797
reader := strings.NewReader(rawThermalData)
98-
id, err := api.UploadThermalRaw(reader, nil)
98+
id, err := api.UploadVideo(reader, nil)
9999
assert.NoError(t, err)
100100
assert.NotEmpty(t, id)
101101
}
@@ -182,9 +182,9 @@ func getMimeParts(r *http.Request) (map[string]interface{}, string) {
182182
return data, fileData
183183
}
184184

185-
//GetUploadThermalRawServer checks that the message is multipart and contains the required multipartmime file:file and Value:data
185+
//GetUploadVideoServer checks that the message is multipart and contains the required multipartmime file:file and Value:data
186186
//and Authorization header
187-
func GetUploadThermalRawServer(t *testing.T) *httptest.Server {
187+
func GetUploadVideoServer(t *testing.T) *httptest.Server {
188188
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
189189
assert.Equal(t, http.MethodPost, r.Method)
190190
assert.NotEmpty(t, r.Header.Get("Authorization"))
@@ -218,7 +218,7 @@ func randomRegister() (*CacophonyAPI, error) {
218218
return Register(randString(20), randString(20), defaultGroup, apiURL, int(rand.Int31()))
219219
}
220220

221-
func TestAPIUploadThermalRaw(t *testing.T) {
221+
func TestAPIUploadVideo(t *testing.T) {
222222
defer newFs(t, "")()
223223
api, err := randomRegister()
224224
require.NoError(t, err)
@@ -227,7 +227,7 @@ func TestAPIUploadThermalRaw(t *testing.T) {
227227
assert.NoError(t, err)
228228
defer reader.Close()
229229

230-
id, err := api.UploadThermalRaw(reader, nil)
230+
id, err := api.UploadVideo(reader, nil)
231231
assert.NoError(t, err)
232232
assert.NotEmpty(t, id)
233233
}
@@ -304,7 +304,7 @@ func TestRegisterAndNew(t *testing.T) {
304304
assert.NoError(t, err)
305305
defer reader.Close()
306306

307-
id, err := api2.UploadThermalRaw(reader, nil)
307+
id, err := api2.UploadVideo(reader, nil)
308308
assert.NoError(t, err, "check that api can upload recordings")
309309
assert.NotEmpty(t, id, "check that recording id is not 0")
310310

@@ -426,7 +426,7 @@ func TestDeviceReregister(t *testing.T) {
426426
assert.NoError(t, err)
427427
defer reader.Close()
428428

429-
id, err := api2.UploadThermalRaw(reader, nil)
429+
id, err := api2.UploadVideo(reader, nil)
430430
assert.NoError(t, err)
431431
assert.NotEmpty(t, id)
432432
}

0 commit comments

Comments
 (0)