Skip to content

Commit

Permalink
Fix missing accept header for tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
sbosio committed Nov 6, 2024
1 parent 82d973e commit c3aa635
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions packages/cli/test/unit/commands/ps/index.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ const hourAgo = new Date(Date.now() - (60 * 60 * 1000))
const hourAgoStr = strftime('%Y/%m/%d %H:%M:%S %z', hourAgo)

function stubAccountQuota(code: number, body: Record<string, unknown>) {
nock('https://api.heroku.com', {reqheaders: {accept: 'application/vnd.heroku+json; version=3.process-tier'}})
nock('https://api.heroku.com', {reqheaders: {accept: 'application/vnd.heroku+json; version=3.sdk'}})
.get('/apps/myapp')
.reply(200, {process_tier: 'eco', owner: {id: '1234'}, id: '6789'})
nock('https://api.heroku.com')
nock('https://api.heroku.com', {reqheaders: {accept: 'application/vnd.heroku+json; version=3.sdk'}})
.get('/apps/myapp/dynos')
.reply(200, [{command: 'bash', size: 'Eco', name: 'run.1', type: 'run', updated_at: hourAgo, state: 'up'}])
nock('https://api.heroku.com')
nock('https://api.heroku.com', {reqheaders: {accept: 'application/vnd.heroku+json; version=3.sdk'}})
.get('/account')
.reply(200, {id: '1234'})
nock('https://api.heroku.com', {reqheaders: {Accept: 'application/vnd.heroku+json; version=3.account-quotas'}})
Expand All @@ -26,21 +26,21 @@ function stubAccountQuota(code: number, body: Record<string, unknown>) {
}

function stubAppAndAccount() {
nock('https://api.heroku.com', {reqheaders: {Accept: 'application/vnd.heroku+json; version=3.process-tier'}})
nock('https://api.heroku.com', {reqheaders: {Accept: 'application/vnd.heroku+json; version=3.sdk'}})
.get('/apps/myapp')
.reply(200, {process_tier: 'basic', owner: {id: '1234'}, id: '6789'})
nock('https://api.heroku.com')
nock('https://api.heroku.com', {reqheaders: {accept: 'application/vnd.heroku+json; version=3.sdk'}})
.get('/account')
.reply(200, {id: '1234'})
}

describe('ps', function () {
describe.only('ps', function () {
afterEach(function () {
nock.cleanAll()
})

it('shows dyno list', async function () {
const api = nock('https://api.heroku.com')
const api = nock('https://api.heroku.com', {reqheaders: {accept: 'application/vnd.heroku+json; version=3.sdk'}})
.get('/apps/myapp/dynos')
.reply(200, [
{command: 'npm start', size: 'Eco', name: 'web.1', type: 'web', updated_at: hourAgo, state: 'up'},
Expand Down Expand Up @@ -69,7 +69,7 @@ describe('ps', function () {
})

it('shows dyno list for Fir apps', async function () {
const api = nock('https://api.heroku.com')
const api = nock('https://api.heroku.com', {reqheaders: {accept: 'application/vnd.heroku+json; version=3.sdk'}})
.get('/apps/myapp/dynos')
.reply(200, [
{command: 'npm start', size: '1X-Classic', name: 'web.4ed720fa31-ur8z1', type: 'web', updated_at: hourAgo, state: 'up'},
Expand Down Expand Up @@ -100,7 +100,7 @@ describe('ps', function () {
})

it('shows shield dynos in dyno list for apps in a shielded private space', async function () {
const api = nock('https://api.heroku.com')
const api = nock('https://api.heroku.com', {reqheaders: {accept: 'application/vnd.heroku+json; version=3.sdk'}})
.get('/apps/myapp')
.reply(200, {space: {shield: true}})
.get('/apps/myapp/dynos')
Expand Down Expand Up @@ -132,7 +132,7 @@ describe('ps', function () {
})

it('errors when no dynos found', async function () {
const api = nock('https://api.heroku.com')
const api = nock('https://api.heroku.com', {reqheaders: {accept: 'application/vnd.heroku+json; version=3.sdk'}})
.get('/apps/myapp/dynos')
.reply(200, [
{command: 'npm start', size: 'Eco', name: 'web.1', type: 'web', updated_at: hourAgo, state: 'up'},
Expand All @@ -157,7 +157,7 @@ describe('ps', function () {
})

it('shows dyno list as json', async function () {
const api = nock('https://api.heroku.com')
const api = nock('https://api.heroku.com', {reqheaders: {accept: 'application/vnd.heroku+json; version=3.sdk'}})
.get('/account')
.reply(200, {id: '1234'})
.get('/apps/myapp')
Expand All @@ -179,7 +179,7 @@ describe('ps', function () {
})

it('shows extended info', async function () {
const api = nock('https://api.heroku.com')
const api = nock('https://api.heroku.com', {reqheaders: {accept: 'application/vnd.heroku+json; version=3.sdk'}})
.get('/account')
.reply(200, {id: '1234'})
.get('/apps/myapp')
Expand Down Expand Up @@ -225,7 +225,7 @@ describe('ps', function () {
})

it('shows extended info for Private Space app', async function () {
const api = nock('https://api.heroku.com')
const api = nock('https://api.heroku.com', {reqheaders: {accept: 'application/vnd.heroku+json; version=3.sdk'}})
.get('/account')
.reply(200, {id: '1234'})
.get('/apps/myapp')
Expand Down Expand Up @@ -289,7 +289,7 @@ describe('ps', function () {
})

it('shows shield dynos in extended info if app is in a shielded private space', async function () {
const api = nock('https://api.heroku.com')
const api = nock('https://api.heroku.com', {reqheaders: {accept: 'application/vnd.heroku+json; version=3.sdk'}})
.get('/account')
.reply(200, {id: '1234'})
.get('/apps/myapp')
Expand Down Expand Up @@ -463,18 +463,18 @@ describe('ps', function () {
})

it('does not print out for apps that are not owned', async function () {
nock('https://api.heroku.com')
nock('https://api.heroku.com', {reqheaders: {accept: 'application/vnd.heroku+json; version=3.sdk'}})
.get('/account')
.reply(200, {id: '1234'})
nock('https://api.heroku.com', {reqheaders: {Accept: 'application/vnd.heroku+json; version=3.process-tier'}})
nock('https://api.heroku.com', {reqheaders: {Accept: 'application/vnd.heroku+json; version=3.sdk'}})
.get('/apps/myapp')
.reply(200, {
process_tier: 'eco', owner: {id: '5678'},
})
nock('https://api.heroku.com', {reqheaders: {Accept: 'application/vnd.heroku+json; version=3.account-quotas'}})
.get('/accounts/1234/actions/get-quota')
.reply(200, {account_quota: 1000, quota_used: 1, apps: []})
const dynos = nock('https://api.heroku.com')
const dynos = nock('https://api.heroku.com', {reqheaders: {accept: 'application/vnd.heroku+json; version=3.sdk'}})
.get('/apps/myapp/dynos')
.reply(200, [{command: 'bash', size: 'Eco', name: 'run.1', type: 'run', updated_at: hourAgo, state: 'up'}])
const ecoExpression = heredoc`
Expand All @@ -496,13 +496,13 @@ describe('ps', function () {
})

it('does not print out for non-eco apps', async function () {
nock('https://api.heroku.com')
nock('https://api.heroku.com', {reqheaders: {accept: 'application/vnd.heroku+json; version=3.sdk'}})
.get('/account')
.reply(200, {id: '1234'})
nock('https://api.heroku.com', {reqheaders: {Accept: 'application/vnd.heroku+json; version=3.process-tier'}})
nock('https://api.heroku.com', {reqheaders: {Accept: 'application/vnd.heroku+json; version=3.sdk'}})
.get('/apps/myapp')
.reply(200, {process_tier: 'eco', owner: {id: 1234}})
const dynos = nock('https://api.heroku.com')
const dynos = nock('https://api.heroku.com', {reqheaders: {accept: 'application/vnd.heroku+json; version=3.sdk'}})
.get('/apps/myapp/dynos')
.reply(200, [{command: 'bash', size: 'Eco', name: 'run.1', type: 'run', updated_at: hourAgo, state: 'up'}])
const ecoExpression = heredoc`
Expand Down Expand Up @@ -542,7 +542,7 @@ describe('ps', function () {
})

it('logs to stdout and exits zero when no dynos', async function () {
const dynos = nock('https://api.heroku.com')
const dynos = nock('https://api.heroku.com', {reqheaders: {accept: 'application/vnd.heroku+json; version=3.sdk'}})
.get('/apps/myapp/dynos')
.reply(200, [])
stubAppAndAccount()
Expand Down

0 comments on commit c3aa635

Please sign in to comment.