Skip to content

Commit

Permalink
Use our typical casing for [nodeping] label (#5715)
Browse files Browse the repository at this point in the history
* Use our typical casing for [nodeping] label

* Fix test + reformat
  • Loading branch information
paulmelnikow authored Oct 16, 2020
1 parent af3f720 commit 43f7adb
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 62 deletions.
8 changes: 2 additions & 6 deletions services/nodeping/nodeping-status.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,13 @@ module.exports = class NodePingStatus extends BaseJsonService {
static examples = [
{
title: 'NodePing status',
namedParams: {
checkUuid: exampleCheckUuid,
},
namedParams: { checkUuid: exampleCheckUuid },
queryParams: exampleQueryParams,
staticPreview: renderWebsiteStatus({ isUp: true }),
},
]

static defaultBadgeData = {
label: 'Status',
}
static defaultBadgeData = { label: 'status' }

async fetch({ checkUuid }) {
const rows = await this._requestJson({
Expand Down
27 changes: 5 additions & 22 deletions services/nodeping/nodeping-status.tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ const t = (module.exports = require('../tester').createServiceTester())

t.create('NodePing status')
.get('/jkiwn052-ntpp-4lbb-8d45-ihew6d9ucoei.json')
.expectBadge({
label: 'Status',
message: Joi.equal('up', 'down').required(),
})
.expectBadge({ label: 'status', message: Joi.equal('up', 'down').required() })

t.create('NodePing status - up')
.get('/jkiwn052-ntpp-4lbb-8d45-ihew6d9ucoei.json')
Expand All @@ -19,10 +16,7 @@ t.create('NodePing status - up')
)
.reply(200, [{ su: true }])
)
.expectBadge({
label: 'Status',
message: 'up',
})
.expectBadge({ label: 'status', message: 'up' })

t.create('NodePing status - down')
.get('/jkiwn052-ntpp-4lbb-8d45-ihew6d9ucoei.json')
Expand All @@ -33,10 +27,7 @@ t.create('NodePing status - down')
)
.reply(200, [{ su: false }])
)
.expectBadge({
label: 'Status',
message: 'down',
})
.expectBadge({ label: 'status', message: 'down' })

t.create('NodePing status - custom up color/message')
.get(
Expand All @@ -49,11 +40,7 @@ t.create('NodePing status - custom up color/message')
)
.reply(200, [{ su: true }])
)
.expectBadge({
label: 'Status',
message: 'happy',
color: 'blue',
})
.expectBadge({ label: 'status', message: 'happy', color: 'blue' })

t.create('NodePing status - custom down color/message')
.get(
Expand All @@ -66,8 +53,4 @@ t.create('NodePing status - custom down color/message')
)
.reply(200, [{ su: false }])
)
.expectBadge({
label: 'Status',
message: 'sad',
color: 'yellow',
})
.expectBadge({ label: 'status', message: 'sad', color: 'yellow' })
13 changes: 3 additions & 10 deletions services/nodeping/nodeping-uptime.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,17 @@ const sampleCheckUuid = 'jkiwn052-ntpp-4lbb-8d45-ihew6d9ucoei'
module.exports = class NodePingUptime extends BaseJsonService {
static category = 'monitoring'

static route = {
base: 'nodeping/uptime',
pattern: ':checkUuid',
}
static route = { base: 'nodeping/uptime', pattern: ':checkUuid' }

static examples = [
{
title: 'NodePing uptime',
namedParams: {
checkUuid: sampleCheckUuid,
},
namedParams: { checkUuid: sampleCheckUuid },
staticPreview: this.render({ uptime: 99.999 }),
},
]

static defaultBadgeData = {
label: 'Uptime',
}
static defaultBadgeData = { label: 'uptime' }

static formatPercentage(uptime) {
if (uptime === 100.0) {
Expand Down
29 changes: 5 additions & 24 deletions services/nodeping/nodeping-uptime.tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ const { isPercentage } = require('../test-validators')

t.create('NodePing uptime')
.get('/jkiwn052-ntpp-4lbb-8d45-ihew6d9ucoei.json')
.expectBadge({
label: 'Uptime',
message: isPercentage,
})
.expectBadge({ label: 'uptime', message: isPercentage })

t.create('NodePing uptime - 100%')
.get('/jkiwn052-ntpp-4lbb-8d45-ihew6d9ucoei.json')
Expand All @@ -23,11 +20,7 @@ t.create('NodePing uptime - 100%')
)
.reply(200, [{ uptime: 100 }])
)
.expectBadge({
label: 'Uptime',
message: '100%',
color: 'brightgreen',
})
.expectBadge({ label: 'uptime', message: '100%', color: 'brightgreen' })

t.create('NodePing uptime - 99.999%')
.get('/jkiwn052-ntpp-4lbb-8d45-ihew6d9ucoei.json')
Expand All @@ -42,11 +35,7 @@ t.create('NodePing uptime - 99.999%')
)
.reply(200, [{ uptime: 99.999 }])
)
.expectBadge({
label: 'Uptime',
message: '99.999%',
color: 'green',
})
.expectBadge({ label: 'uptime', message: '99.999%', color: 'green' })

t.create('NodePing uptime - 99.001%')
.get('/jkiwn052-ntpp-4lbb-8d45-ihew6d9ucoei.json')
Expand All @@ -61,11 +50,7 @@ t.create('NodePing uptime - 99.001%')
)
.reply(200, [{ uptime: 99.001 }])
)
.expectBadge({
label: 'Uptime',
message: '99.001%',
color: 'yellow',
})
.expectBadge({ label: 'uptime', message: '99.001%', color: 'yellow' })

t.create('NodePing uptime - 90.001%')
.get('/jkiwn052-ntpp-4lbb-8d45-ihew6d9ucoei.json')
Expand All @@ -80,8 +65,4 @@ t.create('NodePing uptime - 90.001%')
)
.reply(200, [{ uptime: 90.001 }])
)
.expectBadge({
label: 'Uptime',
message: '90.001%',
color: 'red',
})
.expectBadge({ label: 'uptime', message: '90.001%', color: 'red' })

0 comments on commit 43f7adb

Please sign in to comment.