diff options
author | Chocobozzz <me@florianbigard.com> | 2018-06-29 11:29:23 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-06-29 11:29:23 +0200 |
commit | 4bbfc6c606c8d3794bae25c64c516120af41f4eb (patch) | |
tree | 8d6012f3c04e55e7325e3f00eb9061776cc7a953 /server/tests/utils/requests/requests.ts | |
parent | 3ff5a19b4c988d6c712b7ce63c4cf04f99d047ce (diff) | |
download | PeerTube-4bbfc6c606c8d3794bae25c64c516120af41f4eb.tar.gz PeerTube-4bbfc6c606c8d3794bae25c64c516120af41f4eb.tar.zst PeerTube-4bbfc6c606c8d3794bae25c64c516120af41f4eb.zip |
API: Add ability to update video channel avatar
Diffstat (limited to 'server/tests/utils/requests/requests.ts')
-rw-r--r-- | server/tests/utils/requests/requests.ts | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/server/tests/utils/requests/requests.ts b/server/tests/utils/requests/requests.ts index b6195089d..ebde692cd 100644 --- a/server/tests/utils/requests/requests.ts +++ b/server/tests/utils/requests/requests.ts | |||
@@ -1,5 +1,6 @@ | |||
1 | import * as request from 'supertest' | 1 | import * as request from 'supertest' |
2 | import { buildAbsoluteFixturePath } from '../miscs/miscs' | 2 | import { buildAbsoluteFixturePath } from '../miscs/miscs' |
3 | import { isAbsolute, join } from 'path' | ||
3 | 4 | ||
4 | function makeGetRequest (options: { | 5 | function makeGetRequest (options: { |
5 | url: string, | 6 | url: string, |
@@ -45,7 +46,7 @@ function makeUploadRequest (options: { | |||
45 | url: string, | 46 | url: string, |
46 | method?: 'POST' | 'PUT', | 47 | method?: 'POST' | 'PUT', |
47 | path: string, | 48 | path: string, |
48 | token: string, | 49 | token?: string, |
49 | fields: { [ fieldName: string ]: any }, | 50 | fields: { [ fieldName: string ]: any }, |
50 | attaches: { [ attachName: string ]: any }, | 51 | attaches: { [ attachName: string ]: any }, |
51 | statusCodeExpected?: number | 52 | statusCodeExpected?: number |
@@ -122,6 +123,29 @@ function makePutBodyRequest (options: { | |||
122 | .expect(options.statusCodeExpected) | 123 | .expect(options.statusCodeExpected) |
123 | } | 124 | } |
124 | 125 | ||
126 | function updateAvatarRequest (options: { | ||
127 | url: string, | ||
128 | path: string, | ||
129 | accessToken: string, | ||
130 | fixture: string | ||
131 | }) { | ||
132 | let filePath = '' | ||
133 | if (isAbsolute(options.fixture)) { | ||
134 | filePath = options.fixture | ||
135 | } else { | ||
136 | filePath = join(__dirname, '..', '..', 'fixtures', options.fixture) | ||
137 | } | ||
138 | |||
139 | return makeUploadRequest({ | ||
140 | url: options.url, | ||
141 | path: options.path, | ||
142 | token: options.accessToken, | ||
143 | fields: {}, | ||
144 | attaches: { avatarfile: filePath }, | ||
145 | statusCodeExpected: 200 | ||
146 | }) | ||
147 | } | ||
148 | |||
125 | // --------------------------------------------------------------------------- | 149 | // --------------------------------------------------------------------------- |
126 | 150 | ||
127 | export { | 151 | export { |
@@ -129,5 +153,6 @@ export { | |||
129 | makeUploadRequest, | 153 | makeUploadRequest, |
130 | makePostBodyRequest, | 154 | makePostBodyRequest, |
131 | makePutBodyRequest, | 155 | makePutBodyRequest, |
132 | makeDeleteRequest | 156 | makeDeleteRequest, |
157 | updateAvatarRequest | ||
133 | } | 158 | } |