Files
shields/services/powershellgallery/powershellgallery.tester.js
T
Tyler James LeonhardtandPaul Melnikow 499ea363e0 Add PowerShell Gallery platform support (#2465)
Now that we have [PowerShell Core](https://github.com/powershell/powershell) the cross-plat version of PowerShell... it'd be really cool to have a badge that shows the OS's that your module works on.

On the PowerShell Gallery, users can do this by using the tags `Windows` `MacOS` `Linux`. In this PR, I use the PowerShell Gallery API to grab the tags from that package and display `windows` `macos` `linux` if they exist.

The result is:
![](https://i.imgur.com/auXUkJJ.png)

which aligns with Conda and Cocoapods
2018-12-06 13:23:40 -05:00

75 lines
1.8 KiB
JavaScript

'use strict'
const Joi = require('joi')
const ServiceTester = require('../service-tester')
const {
isMetric,
isVPlusDottedVersionNClauses,
isVPlusDottedVersionNClausesWithOptionalSuffix,
} = require('../test-validators')
const isPlatform = Joi.string().regex(
/^(windows|linux|macos)( \| (windows|linux|macos))*$/
)
const t = new ServiceTester({
id: 'powershellgallery',
title: 'PowerShell Gallery',
})
module.exports = t
t.create('total downloads (valid)')
.get('/dt/ACMESharp.json')
.expectJSONTypes(
Joi.object().keys({
name: 'downloads',
value: isMetric,
})
)
t.create('total downloads (not found)')
.get('/dt/not-a-real-package.json')
.expectJSON({ name: 'downloads', value: 'not found' })
t.create('version (valid)')
.get('/v/ACMESharp.json')
.expectJSONTypes(
Joi.object().keys({
name: 'powershell gallery',
value: isVPlusDottedVersionNClauses,
})
)
t.create('version (not found)')
.get('/v/not-a-real-package.json')
.expectJSON({ name: 'powershell gallery', value: 'not found' })
t.create('version (pre) (valid)')
.get('/vpre/ACMESharp.json')
.expectJSONTypes(
Joi.object().keys({
name: 'powershell gallery',
value: isVPlusDottedVersionNClausesWithOptionalSuffix,
})
)
t.create('version (pre) (not found)')
.get('/vpre/not-a-real-package.json')
.expectJSON({ name: 'powershell gallery', value: 'not found' })
t.create('platform (valid')
.get('/p/DNS.1.1.1.1.json')
.expectJSONTypes(
Joi.object().keys({
name: 'platform',
value: isPlatform,
})
)
t.create('platform (no tags)')
.get('/p/ACMESharp.json')
.expectJSON({ name: 'platform', value: 'not specified' })
t.create('platform (not found)')
.get('/p/not-a-real-package.json')
.expectJSON({ name: 'platform', value: 'not found' })