generated from NatoBoram/gigachad.ts
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrepositories.test.ts
62 lines (52 loc) · 1.68 KB
/
repositories.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import { describe, test } from "vitest"
import {
BITBUCKET_SERVER_TEST_PROJECT_KEY,
BITBUCKET_SERVER_TEST_PROJECT_NAME,
} from "../env.js"
import { client } from "./client.js"
describe("Repositories", { concurrent: false, sequential: true }, () => {
const projectKey = BITBUCKET_SERVER_TEST_PROJECT_KEY
const projectName = BITBUCKET_SERVER_TEST_PROJECT_NAME
const slug = "test-repository"
const name = "Test Repository"
test("Create repository", async ({ expect }) => {
const created = await client.POST(
"/api/latest/projects/{projectKey}/repos",
{ params: { path: { projectKey } }, body: { name, scmId: "git", slug } },
)
if (created.error)
console.error("Failed to create a repository", created.error)
expect(created).toMatchObject({
data: {
slug,
name,
project: { key: projectKey, name: projectName },
scmId: "git",
},
response: { status: 201 },
})
})
test("Get a repository", async ({ expect }) => {
const repository = await client.GET(
"/api/latest/projects/{projectKey}/repos/{repositorySlug}",
{ params: { path: { projectKey, repositorySlug: slug } } },
)
if (repository.error)
console.error("Failed to get a repository", repository.error)
expect(repository.data).toMatchObject({
slug,
name,
project: { key: projectKey, name: projectName },
scmId: "git",
})
})
test("Delete a repository", async ({ expect }) => {
const deleted = await client.DELETE(
"/api/latest/projects/{projectKey}/repos/{repositorySlug}",
{ params: { path: { projectKey, repositorySlug: slug } } },
)
if (deleted.error)
console.error("Failed to delete a repository", deleted.error)
expect(deleted.response.status).toBe(202)
})
})