Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix service tests on windows; run [crates] (to prove service tests still run) #8786

Merged
merged 2 commits into from
Jan 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions core/base-service/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ class InvalidService extends Error {
}
}

function getServicePaths(pattern) {
return glob.sync(toUnixPath(path.join(serviceDir, '**', pattern)))
}

async function loadServiceClasses(servicePaths) {
if (!servicePaths) {
servicePaths = glob.sync(
toUnixPath(path.join(serviceDir, '**', '*.service.js'))
)
servicePaths = getServicePaths('*.service.js')
}

const serviceClasses = []
Expand Down Expand Up @@ -102,15 +104,16 @@ async function collectDefinitions() {

async function loadTesters() {
return Promise.all(
glob
.sync(path.join(serviceDir, '**', '*.tester.js'))
.map(async path => await import(`file://${path}`))
getServicePaths('*.tester.js').map(
async path => await import(`file://${path}`)
)
)
}

export {
InvalidService,
loadServiceClasses,
getServicePaths,
checkNames,
collectDefinitions,
loadTesters,
Expand Down
18 changes: 17 additions & 1 deletion core/base-service/loader.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import path from 'path'
import { fileURLToPath } from 'url'
import chai from 'chai'
import chaiAsPromised from 'chai-as-promised'
import { loadServiceClasses, InvalidService } from './loader.js'
import {
loadServiceClasses,
getServicePaths,
InvalidService,
} from './loader.js'
chai.use(chaiAsPromised)

const { expect } = chai
Expand Down Expand Up @@ -65,3 +69,15 @@ describe('loadServiceClasses function', function () {
).to.eventually.have.length(5)
})
})

describe('getServicePaths', function () {
// these tests just make sure we discover a
// plausibly large number of .service and .tester files
it('finds a non-zero number of services in the project', function () {
expect(getServicePaths('*.service.js')).to.have.length.above(400)
})

it('finds a non-zero number of testers in the project', function () {
expect(getServicePaths('*.tester.js')).to.have.length.above(400)
})
})