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

Function executeTest

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

Source from the content-addressed store, hash-verified

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