chore: remove chaos test

remove-chaos-test
Amio 2025-06-03 09:02:28 +08:00
rodzic 0a48294c2e
commit 47e529233c
3 zmienionych plików z 319 dodań i 503 usunięć

768
package-lock.json wygenerowano

Plik diff jest za duży Load Diff

Wyświetl plik

@ -60,7 +60,6 @@
"next": "^14.2.22",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"supertest": "^6.2.2",
"tsx": "^4.7.1",
"typescript": "^5.0.2"
},

Wyświetl plik

@ -1,53 +0,0 @@
const assert = require('assert')
const tap = require('tap')
const request = require('supertest')
const micro = require('micro')
const badgen = require('../service.js')
const liveFns = require('../libs/live-fns/_index.js')
// process.env.TARGET should be the service url
// - "https://badgen-canary.now.sh"
// - "http://localhost:3000"
const service = process.env.TARGET || micro(badgen)
const isSvg = str => str.trim().startsWith('<svg ')
const badgeTests = [
'/badge/npm/v1.2.3',
'/badge/npm/v1.2.3/blue',
'/badge/npm/v1.2.3/FAD',
'/badge/npm/v1.2.3/FAD?icon=npm',
'/npm/v/express',
'/npm/v/babel-core',
'/npm/v/ava/next',
'/npm/v/next/canary',
'/npm/v/@nestjs/core?icon=npm&label='
]
badgeTests.forEach(badgePath => {
tap.test(badgePath, t => {
return request(service)
.get(badgePath)
.expect(200)
.expect('Content-Type', /svg\+xml/)
.then(res => assert(isSvg(res.body.toString())))
})
})
const keywords = ['badge', 'v', 'nls', 'license', 'red']
const chaosTests = new Array(10).fill().map(undef => {
const keys = keywords.concat(Object.keys(liveFns))
const len = Math.ceil(Math.random() * 5)
const args = new Array(len).fill().map(undef => {
return keys[Math.floor(Math.random() * keys.length)]
})
return `/${args.join('/')}`
})
chaosTests.forEach(badgePath => {
tap.test(badgePath, t => {
return request(service)
.get(badgePath)
.expect('Content-Type', /svg\+xml/)
.then(res => assert(isSvg(res.body.toString())))
})
})