Skip to content

Commit

Permalink
Remove try and catch within test
Browse files Browse the repository at this point in the history
  • Loading branch information
emibloque committed May 7, 2019
1 parent 565e1cf commit 18e2292
Showing 1 changed file with 34 additions and 38 deletions.
72 changes: 34 additions & 38 deletions test/github-issues/4096/issue-4096.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,43 +19,39 @@ describe("github issues > #4096 SQLite support for orUpdate", () => {
after(() => closeTestingConnections(connections));

it("should overwrite using current value in SQLite", () => Promise.all(connections.map(async connection => {
try {
const user1 = new User();
user1.email = "example@example.org";
user1.username = "example";
user1.bio = "My bio";

const user2 = new User();
user2.email = "example@example.org";
user2.username = "example";
user2.bio = "Updated bio";

const UserRepository = connection.manager.getRepository(User);

await UserRepository
.createQueryBuilder()
.insert()
.into(User)
.values(user1)
.execute();

await UserRepository
.createQueryBuilder()
.insert()
.into(User)
.values(user2)
.orUpdate({
conflict_target: [ "email", "username" ],
overwrite: ["bio"],
})
.execute();

const users = await UserRepository.find();
expect(users).not.to.be.undefined;
expect(users).to.have.lengthOf(1);
expect(users[0]).to.includes({ bio: "Updated bio" });
} catch (err) {
throw new Error(err);
}
const user1 = new User();
user1.email = "example@example.org";
user1.username = "example";
user1.bio = "My bio";

const user2 = new User();
user2.email = "example@example.org";
user2.username = "example";
user2.bio = "Updated bio";

const UserRepository = connection.manager.getRepository(User);

await UserRepository
.createQueryBuilder()
.insert()
.into(User)
.values(user1)
.execute();

await UserRepository
.createQueryBuilder()
.insert()
.into(User)
.values(user2)
.orUpdate({
conflict_target: [ "email", "username" ],
overwrite: ["bio"],
})
.execute();

const users = await UserRepository.find();
expect(users).not.to.be.undefined;
expect(users).to.have.lengthOf(1);
expect(users[0]).to.includes({ bio: "Updated bio" });
})));
});

0 comments on commit 18e2292

Please sign in to comment.