<commit_before>const { registrationPinModel } = require('../../../../src/services/user/model');

let createdUserIds = [];
const tempPinIds = [];

const rnd = () => Math.round(Math.random() * 10000);

const createTestUser = (appPromise, opt) => async ({
	// required fields for user
	firstName = 'Max',
	lastName = 'Mustermann',
	birthday = undefined,
	email = `max${`${Date.now()}_${rnd()}`}<EMAIL>`,
	schoolId = opt.schoolId,
	accounts = [], // test if it has a effect
	roles = [],
	discoverable = undefined,
	firstLogin = false,
	// manual cleanup, e.g. when testing delete:
	manualCleanup = false,
	...otherParams
} = {}) => {
	const app = await appPromise;
	const registrationPin = await app.service('registrationPins').create({ email, verified: true, silent: true });
	tempPinIds.push(registrationPin);

	const user = await app.service('users').create({
		firstName,
		lastName,
		birthday,
		email,
		schoolId,
		accounts,
		roles,
		discoverable,
		preferences: {
			firstLogin,
		},
		...otherParams,
	});

	if (!manualCleanup) {
		createdUserIds.push(user._id.toString());
	}
	return user;
};

const cleanup = (appPromise) => async () => {
	const app = await appPromise;
	if (createdUserIds.length === 0) {
		return Promise.resolve();
	}
	const ids = createdUserIds;
	createdUserIds = [];
	const promises = ids.map((id) => app.service('users').remove(id));
	promises.push(registrationPinModel.deleteMany({ _id: { $in: tempPinIds.map((p) => p._id) } }));
	return Promise.all(promises);
};

module.exports = (app, opt) => ({
	create: createTestUser(app, opt),
	cleanup: cleanup(app),
	info: createdUserIds,
	tempPinIds,
});<commit_msg>sc-8179 build repaired<commit_after>const { registrationPinModel } = require('../../../../src/services/user/model');

let createdUserIds = [];

const rnd = () => Math.round(Math.random() * 10000);

const createTestUser = (appPromise, opt) => async ({
	// required fields for user
	firstName = 'Max',
	lastName = 'Mustermann',
	birthday = undefined,
	email = `<EMAIL>${`${Date.now()}_${rnd()}`}<EMAIL>`,
	schoolId = opt.schoolId,
	accounts = [], // test if it has a effect
	roles = [],
	discoverable = undefined,
	firstLogin = false,
	// manual cleanup, e.g. when testing delete:
	manualCleanup = false,
	...otherParams
} = {}) => {
	const app = await appPromise;

	const user = await app.service('users').create({
		firstName,
		lastName,
		birthday,
		email,
		schoolId,
		accounts,
		roles,
		discoverable,
		preferences: {
			firstLogin,
		},
		...otherParams,
	});

	if (!manualCleanup) {
		createdUserIds.push(user._id.toString());
	}
	return user;
};

const cleanup = (appPromise) => async () => {
	const app = await appPromise;
	if (createdUserIds.length === 0) {
		return Promise.resolve();
	}
	const ids = createdUserIds;
	createdUserIds = [];
	const promises = ids.map((id) => app.service('users').remove(id));
	return Promise.all(promises);
};

module.exports = (app, opt) => ({
	create: createTestUser(app, opt),
	cleanup: cleanup(app),
	info: createdUserIds,
});
{'fraction_non_alphanumeric': 0.17832283725555187, 'fraction_numerical': 0.005303281405369572, 'mean_word_length': 4.1239388794567065, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1997188', 'n_tokens_mistral': 1080, 'n_tokens_neox': 1020, 'n_words': 232}