MCPcopy
hub / github.com/sequelize/sequelize / executeTest

Function executeTest

test/integration/dialects/postgres/query.test.js:15–44  ·  view source on GitHub ↗
(options, test)

Source from the content-addressed store, hash-verified

13 const teamAlias = 'Toto';
14
15 const executeTest = async (options, test) => {
16 const sequelize = Support.createSequelizeInstance(options);
17
18 const User = sequelize.define('User', { name: DataTypes.STRING, updatedAt: DataTypes.DATE }, { underscored: true });
19 const Team = sequelize.define('Team', { name: DataTypes.STRING });
20 const Task = sequelize.define('Task', { title: DataTypes.STRING });
21
22 User.belongsTo(Task, { as: taskAlias, foreignKey: 'task_id' });
23 User.belongsToMany(Team, { as: teamAlias, foreignKey: 'teamId', through: 'UserTeam' });
24 Team.belongsToMany(User, { foreignKey: 'userId', through: 'UserTeam' });
25
26 await sequelize.sync({ force: true });
27 const team = await Team.create({ name: 'rocket' });
28 const task = await Task.create({ title: 'SuperTask' });
29 const user = await User.create({ name: 'test', task_id: task.id, updatedAt: new Date() });
30 await user[`add${teamAlias}`](team);
31
32 return test(await User.findOne({
33 include: [
34 {
35 model: Task,
36 as: taskAlias
37 },
38 {
39 model: Team,
40 as: teamAlias
41 }
42 ]
43 }));
44 };
45
46 it('should throw due to alias being truncated', async function() {
47 const options = { ...this.sequelize.options, minifyAliases: false };

Callers 1

query.test.jsFile · 0.85

Calls 7

defineMethod · 0.80
belongsToMethod · 0.80
belongsToManyMethod · 0.80
findOneMethod · 0.80
testFunction · 0.50
syncMethod · 0.45
createMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…