Skip to content

Commit

Permalink
fix tests and rename oso param
Browse files Browse the repository at this point in the history
  • Loading branch information
eternauta1337 committed Apr 8, 2024
1 parent 491d4d8 commit 08b4aaa
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 12 deletions.
8 changes: 4 additions & 4 deletions packages/ethernaut-oso/src/tasks/chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require('../scopes/metrics')
'Prints Open Source Observer onchain metrics for a project, including number of contracts, active users, gas usage, and more',
)
.addOptionalParam(
'name',
'project',
'The name or slug of the project',
undefined,
types.string,
Expand All @@ -22,16 +22,16 @@ require('../scopes/metrics')
undefined,
types.string,
)
.setAction(async ({ name, limit, sort }) => {
.setAction(async ({ project, limit, sort }) => {
try {
const oso = new OpenSourceObserver()

const projects = await oso.getChainMetrics(name, limit, sort)
const projects = await oso.getChainMetrics(project, limit, sort)

if (projects.length === 0) {
throw new EthernautCliError(
'ethernaut-oso',
`No projects found for "${name}"`,
`No projects found for "${project}"`,
)
}

Expand Down
8 changes: 4 additions & 4 deletions packages/ethernaut-oso/src/tasks/code.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require('../scopes/metrics')
'Prints Open Source Observer code metrics for a project, including number of Github stars, commits, contributors, and more',
)
.addOptionalParam(
'name',
'project',
'The name or slug of the project',
undefined,
types.string,
Expand All @@ -22,16 +22,16 @@ require('../scopes/metrics')
undefined,
types.string,
)
.setAction(async ({ name, limit, sort }) => {
.setAction(async ({ project, limit, sort }) => {
try {
const oso = new OpenSourceObserver()

const projects = await oso.getCodeMetrics(name, limit, sort)
const projects = await oso.getCodeMetrics(project, limit, sort)

if (projects.length === 0) {
throw new EthernautCliError(
'ethernaut-oso',
`No projects found for "${name}"`,
`No projects found for "${project}"`,
)
}

Expand Down
13 changes: 13 additions & 0 deletions packages/ethernaut-oso/test/tasks/chain.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const { Terminal } = require('ethernaut-common/src/test/terminal')

describe('chain', function () {
const terminal = new Terminal()

before('run', async function () {
await terminal.run('hardhat metrics chain --project ethers.js')
})

it('shows ethers.js', async function () {
terminal.has('project_name: ethers.js')
})
})
8 changes: 4 additions & 4 deletions packages/ethernaut-oso/test/tasks/code.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ describe('code', function () {
const terminal = new Terminal()

before('run', async function () {
await terminal.run('hardhat metrics code ethers.js')
await terminal.run('hardhat metrics code --project ethers.js')
})

it('shows stars', async function () {
const output = terminal.output
const starsLine = output.split('\n').find((line) => line.includes('Stars:'))
const starsLine = output.split('\n').find((line) => line.includes('stars:'))
assert(starsLine, 'Stars line not found in terminal output')

const match = starsLine.match(/Stars:\s(\d+)/)
assert(match, 'No number found after "Stars:"')
const match = starsLine.match(/stars:\s(\d+)/)
assert(match, 'No number found after "stars:"')
})
})

0 comments on commit 08b4aaa

Please sign in to comment.