-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for telemetry:update, fix grpc spelling, display drain after…
… update
- Loading branch information
Showing
6 changed files
with
115 additions
and
21 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -98,7 +98,6 @@ Gdvb | |
getreqs | ||
Ghpcy | ||
githuborg | ||
gprc | ||
hamurai | ||
herokai | ||
herokuapp | ||
|
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
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
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
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
92 changes: 92 additions & 0 deletions
92
packages/cli/test/unit/commands/telemetry/update.unit.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,92 @@ | ||
import {stderr, stdout} from 'stdout-stderr' | ||
import Cmd from '../../../../src/commands/telemetry/update' | ||
import runCommand from '../../../helpers/runCommand' | ||
import * as nock from 'nock' | ||
import expectOutput from '../../../helpers/utils/expectOutput' | ||
import heredoc from 'tsheredoc' | ||
import {expect} from 'chai' | ||
import {appTelemetryDrain1} from '../../../fixtures/telemetry/fixtures' | ||
|
||
describe('telemetry:update', function () { | ||
afterEach(function () { | ||
return nock.cleanAll() | ||
}) | ||
|
||
it('updates a telemetry drain with one field', async function () { | ||
const updatedAppTelemetryDrain = {...appTelemetryDrain1, signals: ['logs']} | ||
nock('https://api.heroku.com', {reqheaders: {Accept: 'application/vnd.heroku+json; version=3.sdk'}}) | ||
.patch(`/telemetry-drains/${appTelemetryDrain1.id}`, {signals: ['logs']}) | ||
.reply(200, updatedAppTelemetryDrain) | ||
|
||
await runCommand(Cmd, [ | ||
appTelemetryDrain1.id, | ||
'--signal', | ||
'logs', | ||
]) | ||
expectOutput(stderr.output, heredoc(` | ||
Updating telemetry drain ${appTelemetryDrain1.id}... | ||
Updating telemetry drain ${appTelemetryDrain1.id}... done | ||
`)) | ||
expectOutput(stdout.output, heredoc(` | ||
=== ${updatedAppTelemetryDrain.id} | ||
App: ${updatedAppTelemetryDrain.owner.name} | ||
Signals: ${updatedAppTelemetryDrain.signals.join(', ')} | ||
Endpoint: ${updatedAppTelemetryDrain.exporter.endpoint} | ||
Kind: ${updatedAppTelemetryDrain.exporter.type} | ||
Headers: x-honeycomb-team: 'your-api-key', x-honeycomb-dataset: 'your-dataset' | ||
`)) | ||
}) | ||
|
||
it('updates a telemetry drain with multiple fields', async function () { | ||
const updatedAppTelemetryDrain = { | ||
...appTelemetryDrain1, | ||
signals: ['logs'], | ||
exporter: { | ||
endpoint: 'https://api-new.honeycomb.io/', | ||
type: 'otlpgrpc', | ||
headers: { | ||
'x-honeycomb-team': 'your-api-key', | ||
'x-honeycomb-dataset': 'your-dataset', | ||
}, | ||
}, | ||
} | ||
nock('https://api.heroku.com', {reqheaders: {Accept: 'application/vnd.heroku+json; version=3.sdk'}}) | ||
.patch(`/telemetry-drains/${appTelemetryDrain1.id}`, { | ||
signals: ['logs'], | ||
exporter: { | ||
endpoint: 'https://api-new.honeycomb.io/', | ||
type: 'otlpgrpc', | ||
}, | ||
}) | ||
.reply(200, updatedAppTelemetryDrain) | ||
|
||
await runCommand(Cmd, [ | ||
appTelemetryDrain1.id, | ||
'--signal', | ||
'logs', | ||
'--endpoint', | ||
'https://api-new.honeycomb.io/', | ||
'--transport', | ||
'grpc', | ||
]) | ||
expectOutput(stderr.output, heredoc(` | ||
Updating telemetry drain ${appTelemetryDrain1.id}... | ||
Updating telemetry drain ${appTelemetryDrain1.id}... done | ||
`)) | ||
expectOutput(stdout.output, heredoc(` | ||
=== ${updatedAppTelemetryDrain.id} | ||
App: ${updatedAppTelemetryDrain.owner.name} | ||
Signals: ${updatedAppTelemetryDrain.signals.join(', ')} | ||
Endpoint: ${updatedAppTelemetryDrain.exporter.endpoint} | ||
Kind: ${updatedAppTelemetryDrain.exporter.type} | ||
Headers: x-honeycomb-team: 'your-api-key', x-honeycomb-dataset: 'your-dataset' | ||
`)) | ||
}) | ||
|
||
it('requires an updated attribute to be provided', async function () { | ||
const errorMessage = 'Requires either --signal, --endpoint, --transport or HEADERS to be provided.' | ||
await runCommand(Cmd, [appTelemetryDrain1.id]).catch(error => { | ||
expect(error.message).to.contain(errorMessage) | ||
}) | ||
}) | ||
}) |