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

Function executeTest

test/integration/dialects/postgres/query.test.js:15–44  ·  test/integration/dialects/postgres/query.test.js::executeTest
(options, test)

Source from the content-addressed store, hash-verified

13 const teamAlias = class="st">'Toto';
14
15 const executeTest = async (options, test) => {
16 const sequelize = Support.createSequelizeInstance(options);
17
18 const User = sequelize.define(class="st">'User', { name: DataTypes.STRING, updatedAt: DataTypes.DATE }, { underscored: true });
19 const Team = sequelize.define(class="st">'Team', { name: DataTypes.STRING });
20 const Task = sequelize.define(class="st">'Task', { title: DataTypes.STRING });
21
22 User.belongsTo(Task, { as: taskAlias, foreignKey: class="st">'task_id' });
23 User.belongsToMany(Team, { as: teamAlias, foreignKey: class="st">'teamId', through: class="st">'UserTeam' });
24 Team.belongsToMany(User, { foreignKey: class="st">'userId', through: class="st">'UserTeam' });
25
26 await sequelize.sync({ force: true });
27 const team = await Team.create({ name: class="st">'rocket' });
28 const task = await Task.create({ title: class="st">'SuperTask' });
29 const user = await User.create({ name: class="st">'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(class="st">'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