Skip to content

Commit

Permalink
fix: added getFileContents tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ivankatliarchuk committed Oct 2, 2022
1 parent b5de611 commit a1af3e2
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
16 changes: 16 additions & 0 deletions source/platforms/gitlab/_tests/_gitlab_api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,20 @@ describe("GitLab API", () => {
const { response } = loadFixture("getCompareChanges")
expect(result).toEqual(response.diffs)
})

it("getFileContents", async () => {
const { nockDone } = await nockBack("getFileContents.json")
const parameters: { filePath: string; ref: string; expected: string }[] = [
{
filePath: "Gemfile",
ref: "master",
expected: "source 'https://rubygems.org'",
},
]
for (let el in parameters) {
let result = await api.getFileContents(parameters[el].filePath, api.repoMetadata.repoSlug, parameters[el].ref)
expect(result).toContain(parameters[el].expected)
}
nockDone()
})
})
22 changes: 22 additions & 0 deletions source/platforms/gitlab/_tests/fixtures/getFileContents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[
{
"scope": "https://gitlab.com",
"method": "GET",
"path": "/api/v4/projects/gitlab-org%2Fgitlab-foss/repository/files/Gemfile?ref=master",
"body": "",
"status": 200,
"response": {
"file_name": "Gemfile",
"file_path": "Gemfile",
"size": 4989,
"encoding": "base64",
"content_sha256": "d1db2dff734c9a5f59b9e994b2f610317a0bdbdf938d4dc2797bb0bd384233f6",
"ref": "master",
"blob_id": "78b0a38bcaae68ca1bd5fc967c9901c854f3d9ab",
"commit_id": "86461e8c72db13d6d334fd107d38aa1b021d030e",
"last_commit_id": "a16398e10f87edd229a12be2f1fc87cd4a76f902",
"execute_filemode": false,
"content": "c291cmNlICdodHRwczovL3J1YnlnZW1zLm9yZycK"
}
}
]

0 comments on commit a1af3e2

Please sign in to comment.