mirror of
https://github.com/theoludwig/programming-challenges.git
synced 2025-05-18 12:02:53 +02:00
refactor(cli): usage of node:test instead of tap
This commit is contained in:
@ -60,7 +60,7 @@ export class Docker {
|
||||
)
|
||||
try {
|
||||
const { stdout, stderr } = await subprocess
|
||||
if (stderr.length !== 0) {
|
||||
if (stderr.length > 0) {
|
||||
throw new Error(stderr)
|
||||
}
|
||||
return {
|
||||
|
@ -1,6 +1,7 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import crypto from 'node:crypto'
|
||||
|
||||
import tap from 'tap'
|
||||
import sinon from 'sinon'
|
||||
|
||||
import { Challenge } from '../Challenge.js'
|
||||
@ -10,7 +11,7 @@ import { parseCommandOutput } from '../../utils/parseCommandOutput.js'
|
||||
|
||||
const gitAffected = new GitAffected()
|
||||
|
||||
await tap.test('services/GitAffected', async (t) => {
|
||||
await test('services/GitAffected', async (t) => {
|
||||
t.afterEach(() => {
|
||||
sinon.restore()
|
||||
})
|
||||
@ -22,19 +23,22 @@ await tap.test('services/GitAffected', async (t) => {
|
||||
})
|
||||
|
||||
await t.test('parseCommandOutput', async (t) => {
|
||||
await t.test('returns the right output array', async (t) => {
|
||||
t.same(parseCommandOutput('1.txt\n 2.txt '), ['1.txt', '2.txt'])
|
||||
await t.test('returns the right output array', async () => {
|
||||
assert.deepStrictEqual(parseCommandOutput('1.txt\n 2.txt '), [
|
||||
'1.txt',
|
||||
'2.txt'
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
await t.test('getAffectedSolutionsFromFiles', async (t) => {
|
||||
await t.test('returns the affected solutions', async (t) => {
|
||||
await t.test('returns the affected solutions', async () => {
|
||||
const files = [
|
||||
'challenges/hello-world/solutions/javascript/function/solution.js',
|
||||
'challenges/is-palindrome/solutions/c/function/input.c'
|
||||
]
|
||||
const solutions = await gitAffected.getAffectedSolutionsFromFiles(files)
|
||||
t.same(solutions, [
|
||||
assert.deepStrictEqual(solutions, [
|
||||
new Solution({
|
||||
challenge: new Challenge({ name: 'hello-world' }),
|
||||
name: 'function',
|
||||
@ -50,10 +54,10 @@ await tap.test('services/GitAffected', async (t) => {
|
||||
|
||||
await t.test(
|
||||
'returns the affected solutions from Dockerfile changes',
|
||||
async (t) => {
|
||||
async () => {
|
||||
const files = ['templates/docker/javascript/Dockerfile']
|
||||
const solutions = await gitAffected.getAffectedSolutionsFromFiles(files)
|
||||
t.same(
|
||||
assert.deepStrictEqual(
|
||||
solutions[0],
|
||||
new Solution({
|
||||
challenge: new Challenge({ name: 'camel-case' }),
|
||||
@ -61,7 +65,7 @@ await tap.test('services/GitAffected', async (t) => {
|
||||
programmingLanguageName: 'javascript'
|
||||
})
|
||||
)
|
||||
t.same(
|
||||
assert.deepStrictEqual(
|
||||
solutions[1],
|
||||
new Solution({
|
||||
challenge: new Challenge({ name: 'first-non-repeating-character' }),
|
||||
@ -74,10 +78,10 @@ await tap.test('services/GitAffected', async (t) => {
|
||||
|
||||
await t.test(
|
||||
'returns the affected solutions from Docker template changes',
|
||||
async (t) => {
|
||||
async () => {
|
||||
const files = ['templates/docker/javascript/package.json']
|
||||
const solutions = await gitAffected.getAffectedSolutionsFromFiles(files)
|
||||
t.same(
|
||||
assert.deepStrictEqual(
|
||||
solutions[0],
|
||||
new Solution({
|
||||
challenge: new Challenge({ name: 'camel-case' }),
|
||||
@ -85,7 +89,7 @@ await tap.test('services/GitAffected', async (t) => {
|
||||
programmingLanguageName: 'javascript'
|
||||
})
|
||||
)
|
||||
t.same(
|
||||
assert.deepStrictEqual(
|
||||
solutions[1],
|
||||
new Solution({
|
||||
challenge: new Challenge({ name: 'first-non-repeating-character' }),
|
||||
@ -98,10 +102,10 @@ await tap.test('services/GitAffected', async (t) => {
|
||||
|
||||
await t.test(
|
||||
'returns the affected solutions from input/output files',
|
||||
async (t) => {
|
||||
async () => {
|
||||
const files = ['challenges/hello-world/test/1/input.txt']
|
||||
const solutions = await gitAffected.getAffectedSolutionsFromFiles(files)
|
||||
t.same(
|
||||
assert.deepStrictEqual(
|
||||
solutions[0],
|
||||
new Solution({
|
||||
challenge: new Challenge({ name: 'hello-world' }),
|
||||
@ -109,7 +113,7 @@ await tap.test('services/GitAffected', async (t) => {
|
||||
programmingLanguageName: 'c'
|
||||
})
|
||||
)
|
||||
t.same(
|
||||
assert.deepStrictEqual(
|
||||
solutions[1],
|
||||
new Solution({
|
||||
challenge: new Challenge({ name: 'hello-world' }),
|
||||
@ -117,7 +121,7 @@ await tap.test('services/GitAffected', async (t) => {
|
||||
programmingLanguageName: 'cpp'
|
||||
})
|
||||
)
|
||||
t.same(
|
||||
assert.deepStrictEqual(
|
||||
solutions[2],
|
||||
new Solution({
|
||||
challenge: new Challenge({ name: 'hello-world' }),
|
||||
@ -125,7 +129,7 @@ await tap.test('services/GitAffected', async (t) => {
|
||||
programmingLanguageName: 'cs'
|
||||
})
|
||||
)
|
||||
t.same(
|
||||
assert.deepStrictEqual(
|
||||
solutions[3],
|
||||
new Solution({
|
||||
challenge: new Challenge({ name: 'hello-world' }),
|
||||
|
Reference in New Issue
Block a user