Skip to content

Commit

Permalink
test(scenario): release assets
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m committed Nov 22, 2017
1 parent 1667120 commit 11fed85
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 0 deletions.
87 changes: 87 additions & 0 deletions test/integration/release-assets-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
const pathResolve = require('path').resolve

const chai = require('chai')
const fixtures = require('@octokit/fixtures')

const GitHub = require('../../')

const mocha = require('mocha')
const describe = mocha.describe
const it = mocha.it
chai.should()

describe('api.github.com', () => {
it('github.repos.*Assets', () => {
const GitHubMock = fixtures.mock('api.github.com/release-assets')
const githubUserA = new GitHub()

var releaseId
var assetId

githubUserA.authenticate({
type: 'token',
token: '0000000000000000000000000000000000000001'
})

githubUserA.repos.getReleaseByTag({
owner: 'octokit-fixture-org',
repo: 'release-assets',
tag: 'v1.0.0'
})

.then(result => {
releaseId = result.data.id

return githubUserA.repos.uploadAsset({
owner: 'octokit-fixture-org',
repo: 'release-assets',
id: releaseId,
filePath: pathResolve(__dirname, 'test-upload.txt'),
name: 'test-upload.txt',
label: 'test'
})
})

.then(result => {
assetId = releaseId

return githubUserA.repos.getAssets({
owner: 'octokit-fixture-org',
repo: 'release-assets',
id: releaseId
})
})

.then(result => {
return githubUserA.repos.getAsset({
owner: 'octokit-fixture-org',
repo: 'release-assets',
id: assetId
})
})

.then(result => {
return githubUserA.repos.editAsset({
owner: 'octokit-fixture-org',
repo: 'release-assets',
id: assetId,
name: 'new-filename.txt',
label: 'new label'
})
})

.then(result => {
return githubUserA.repos.deleteAsset({
owner: 'octokit-fixture-org',
repo: 'release-assets',
id: assetId
})
})

.then((result) => {
GitHubMock.pending().should.deep.equal([])
})

.catch(GitHubMock.explain)
})
})
1 change: 1 addition & 0 deletions test/integration/test-upload.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello, world!

0 comments on commit 11fed85

Please sign in to comment.