aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/peertube-runner/client-cli.ts
blob: ff70e599feb2bde01b328ea067d7b7081641cbb9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */

import { expect } from 'chai'
import { PeerTubeRunnerProcess } from '@server/tests/shared'
import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers, setDefaultVideoChannel } from '@shared/server-commands'

describe('Test peertube-runner program client CLI', function () {
  let server: PeerTubeServer
  let peertubeRunner: PeerTubeRunnerProcess

  before(async function () {
    this.timeout(120_000)

    server = await createSingleServer(1)

    await setAccessTokensToServers([ server ])
    await setDefaultVideoChannel([ server ])

    await server.config.enableRemoteTranscoding()

    peertubeRunner = new PeerTubeRunnerProcess()
    await peertubeRunner.runServer()
  })

  it('Should not have PeerTube instance listed', async function () {
    const data = await peertubeRunner.listRegisteredPeerTubeInstances()

    expect(data).to.not.contain(server.url)
  })

  it('Should register a new PeerTube instance', async function () {
    const registrationToken = await server.runnerRegistrationTokens.getFirstRegistrationToken()

    await peertubeRunner.registerPeerTubeInstance({
      server,
      registrationToken,
      runnerName: 'my super runner',
      runnerDescription: 'super description'
    })
  })

  it('Should list this new PeerTube instance', async function () {
    const data = await peertubeRunner.listRegisteredPeerTubeInstances()

    expect(data).to.contain(server.url)
    expect(data).to.contain('my super runner')
    expect(data).to.contain('super description')
  })

  it('Should still have the configuration after a restart', async function () {
    peertubeRunner.kill()

    await peertubeRunner.runServer()
  })

  it('Should unregister the PeerTube instance', async function () {
    await peertubeRunner.unregisterPeerTubeInstance({ server })
  })

  it('Should not have PeerTube instance listed', async function () {
    const data = await peertubeRunner.listRegisteredPeerTubeInstances()

    expect(data).to.not.contain(server.url)
  })

  after(async function () {
    peertubeRunner.kill()

    await cleanupTests([ server ])
  })
})