]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - scripts/benchmark.ts
Translated using Weblate (Finnish)
[github/Chocobozzz/PeerTube.git] / scripts / benchmark.ts
index 91e8b865afef8a870283759edb897fa09ef3c687..f7f9ad1bf6c600ccb0da1d164c5e747683b7144e 100644 (file)
@@ -55,7 +55,7 @@ async function run () {
       path: '/accounts/peertube',
       headers: buildAPHeader(),
       expecter: (body, status) => {
-        return status === 200 && body.startsWith('{"type":')
+        return status === 200 && body.startsWith('{"@context":')
       }
     },
     {
@@ -63,7 +63,7 @@ async function run () {
       path: '/videos/watch/' + video.uuid,
       headers: buildAPHeader(),
       expecter: (body, status) => {
-        return status === 200 && body.startsWith('{"type":"Video"')
+        return status === 200 && body.startsWith('{"@context":')
       }
     },
     {
@@ -153,21 +153,23 @@ async function run () {
       }
     },
     {
-      title: 'API - watching',
+      title: 'API - views with token',
       method: 'PUT',
       headers: {
         ...buildAuthorizationHeader(),
         ...buildJSONHeader()
       },
       body: JSON.stringify({ currentTime: 2 }),
-      path: '/api/v1/videos/' + video.uuid + '/watching',
+      path: '/api/v1/videos/' + video.uuid + '/views',
       expecter: (body, status) => {
         return status === 204
       }
     },
     {
-      title: 'API - views',
+      title: 'API - views without token',
       method: 'POST',
+      headers: buildJSONHeader(),
+      body: JSON.stringify({ currentTime: 2 }),
       path: '/api/v1/videos/' + video.uuid + '/views',
       expecter: (body, status) => {
         return status === 204
@@ -201,7 +203,7 @@ function runBenchmark (options: {
   headers?: { [ id: string ]: string }
   expecter: Function
 }) {
-  const { method, path, body, expecter, headers } = options
+  const { method = 'GET', path, body, expecter, headers } = options
 
   return new Promise((res, rej) => {
     autocannon({