-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1347 from argos-ci/multiple-project-same-repo
- Loading branch information
Showing
2 changed files
with
137 additions
and
9 deletions.
There are no files selected for viewing
83 changes: 83 additions & 0 deletions
83
apps/backend/src/build-notification/notification.e2e.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { invariant } from "@argos/util/invariant"; | ||
import { beforeEach, describe, expect, it } from "vitest"; | ||
|
||
import { Build } from "@/database/models/Build.js"; | ||
import { BuildNotification } from "@/database/models/BuildNotification.js"; | ||
import { factory } from "@/database/testing/index.js"; | ||
import { setupDatabase } from "@/database/testing/util.js"; | ||
|
||
import { getNotificationPayload } from "./notification.js"; | ||
|
||
describe("#getNotificationPayload", () => { | ||
beforeEach(async () => { | ||
await setupDatabase(); | ||
}); | ||
|
||
describe("with a repository only linked to one project", () => { | ||
let build: Build; | ||
let buildNotification: BuildNotification; | ||
|
||
beforeEach(async () => { | ||
const repository = await factory.GithubRepository.create(); | ||
const [project] = await factory.Project.createMany(2, [ | ||
{ | ||
githubRepositoryId: repository.id, | ||
gitlabProjectId: null, | ||
name: "backend", | ||
}, | ||
{ | ||
githubRepositoryId: null, | ||
gitlabProjectId: null, | ||
name: "frontend", | ||
}, | ||
]); | ||
invariant(project); | ||
build = await factory.Build.create({ projectId: project.id }); | ||
buildNotification = await factory.BuildNotification.create({ | ||
buildId: build.id, | ||
}); | ||
}); | ||
|
||
it("returns argos as context", async () => { | ||
const payload = await getNotificationPayload({ | ||
build, | ||
buildNotification, | ||
}); | ||
expect(payload.context).toBe("argos"); | ||
}); | ||
}); | ||
|
||
describe("with a GitHub repository linked to multiple projects", () => { | ||
let build: Build; | ||
let buildNotification: BuildNotification; | ||
|
||
beforeEach(async () => { | ||
const repository = await factory.GithubRepository.create(); | ||
const [project] = await factory.Project.createMany(2, [ | ||
{ | ||
githubRepositoryId: repository.id, | ||
gitlabProjectId: null, | ||
name: "backend", | ||
}, | ||
{ | ||
githubRepositoryId: repository.id, | ||
gitlabProjectId: null, | ||
name: "frontend", | ||
}, | ||
]); | ||
invariant(project); | ||
build = await factory.Build.create({ projectId: project.id }); | ||
buildNotification = await factory.BuildNotification.create({ | ||
buildId: build.id, | ||
}); | ||
}); | ||
|
||
it("returns argos as context", async () => { | ||
const payload = await getNotificationPayload({ | ||
build, | ||
buildNotification, | ||
}); | ||
expect(payload.context).toBe("argos/backend"); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters