From f05a1c30c15d2ae35c11e241ca039a72eeb7d6ad Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 18 Jan 2018 10:53:54 +0100 Subject: Don't show videos of remote instance after unfollow --- server/tests/utils/users/accounts.ts | 25 ++++++++++++++++++++++++- server/tests/utils/users/users.ts | 2 +- 2 files changed, 25 insertions(+), 2 deletions(-) (limited to 'server/tests/utils/users') diff --git a/server/tests/utils/users/accounts.ts b/server/tests/utils/users/accounts.ts index 0ec7992b3..a5c13c319 100644 --- a/server/tests/utils/users/accounts.ts +++ b/server/tests/utils/users/accounts.ts @@ -1,5 +1,11 @@ +/* tslint:disable:no-unused-expression */ + import { expect } from 'chai' +import { existsSync } from 'fs' +import { join } from 'path' import { Account } from '../../../../shared/models/actors' +import { readdirPromise } from '../../../helpers/core-utils' +import { root } from '../index' import { makeGetRequest } from '../requests/requests' function getAccountsList (url: string, sort = '-createdAt', statusCodeExpected = 200) { @@ -32,10 +38,27 @@ async function expectAccountFollows (url: string, nameWithDomain: string, follow expect(account.followingCount).to.equal(followingCount, message) } +async function checkActorFilesWereRemoved (actorUUID: string, serverNumber: number) { + const testDirectory = 'test' + serverNumber + + for (const directory of [ 'avatars' ]) { + const directoryPath = join(root(), testDirectory, directory) + + const directoryExists = existsSync(directoryPath) + expect(directoryExists).to.be.true + + const files = await readdirPromise(directoryPath) + for (const file of files) { + expect(file).to.not.contain(actorUUID) + } + } +} + // --------------------------------------------------------------------------- export { getAccount, expectAccountFollows, - getAccountsList + getAccountsList, + checkActorFilesWereRemoved } diff --git a/server/tests/utils/users/users.ts b/server/tests/utils/users/users.ts index 12945a805..25351e2c7 100644 --- a/server/tests/utils/users/users.ts +++ b/server/tests/utils/users/users.ts @@ -11,7 +11,7 @@ function createUser ( password: string, videoQuota = 1000000, role: UserRole = UserRole.USER, - specialStatus = 204 + specialStatus = 200 ) { const path = '/api/v1/users' const body = { -- cgit v1.2.3