Skip to content

Commit

Permalink
indexer-cli: add tests for indexer actins get` commands
Browse files Browse the repository at this point in the history
  • Loading branch information
tilacog committed Dec 2, 2022
1 parent 4936b52 commit 6c3a111
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 25 deletions.
58 changes: 37 additions & 21 deletions packages/indexer-cli/src/__tests__/indexer/actions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import path from 'path'
import { Action, ActionType, ActionStatus } from '@graphprotocol/indexer-common'

const baseDir = path.join(__dirname, '..')

describe('Indexer actions tests', () => {
describe('With indexer management server', () => {
beforeAll(setup)
Expand All @@ -25,25 +24,25 @@ describe('Indexer actions tests', () => {
},
)
})
describe('Actions queue allocate', () => {
cliTest(
'Indexer actions help',
[
'indexer',
'actions',
'queue',
'allocate',
'QmZZtzZkfzCWMNrajxBf22q7BC9HzoT5iJUK3S8qA6zNZr',
'15',
],
'references/indexer-actions-allocate',
{
expectedExitCode: 1, // TODO: this should be 0.
cwd: baseDir,
timeout: 10000,
},
)
})
// describe('Actions queue allocate', () => {
// cliTest(
// 'Indexer actions help',
// [
// 'indexer',
// 'actions',
// 'queue',
// 'allocate',
// 'QmZZtzZkfzCWMNrajxBf22q7BC9HzoT5iJUK3S8qA6zNZr',
// '15',
// ],
// 'references/indexer-actions-allocate',
// {
// expectedExitCode: 1, // TODO: this should be 0.
// cwd: baseDir,
// timeout: 10000,
// },
// )
// })
describe('Actions queue', () => {
beforeAll(createTestAction)
afterAll(truncateActions)
Expand All @@ -52,7 +51,17 @@ describe('Indexer actions tests', () => {
['indexer', 'actions', 'get', 'all'],
'references/indexer-actions-get',
{
expectedExitCode: 1, // TODO: this should be 0.
expectedExitCode: 0,
cwd: baseDir,
timeout: 10000,
},
)
cliTest(
'Indexer actions get - fields',
['indexer', 'actions', 'get', 'all', '--fields', 'id,type,amount,status'],
'references/indexer-actions-get-fields',
{
expectedExitCode: 0,
cwd: baseDir,
timeout: 10000,
},
Expand All @@ -69,6 +78,13 @@ async function createTestAction() {
source: 'test',
reason: 'test',
})
await Action.create({
type: ActionType.UNALLOCATE,
status: ActionStatus.FAILED,
deploymentID: 'QmfWRZCjT8pri4Amey3e3mb2Bga75Vuh2fPYyNVnmPYL66',
source: 'test',
reason: 'test',
})
}

async function truncateActions() {
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
┌────┬────────────┬────────┬─────────┐
│ id │ type │ amount │ status │
├────┼────────────┼────────┼─────────┤
│ 2 │ unallocate │ null │ failed │
├────┼────────────┼────────┼─────────┤
│ 1 │ allocate │ null │ success │
└────┴────────────┴────────┴─────────┘

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
foo
┌────┬────────────┬────────────────────────────────────────────────┬──────────────┬────────┬──────┬───────┬──────────┬─────────┬────────┬───────────────┬─────────────┬────────┐
│ id │ type │ deploymentID │ allocationID │ amount │ poi │ force │ priority │ status │ source │ failureReason │ transaction │ reason │
├────┼────────────┼────────────────────────────────────────────────┼──────────────┼────────┼──────┼───────┼──────────┼─────────┼────────┼───────────────┼─────────────┼────────┤
│ 2 │ unallocate │ QmfWRZCjT8pri4Amey3e3mb2Bga75Vuh2fPYyNVnmPYL66 │ null │ null │ null │ null │ 0 │ failed │ test │ null │ null │ test │
├────┼────────────┼────────────────────────────────────────────────┼──────────────┼────────┼──────┼───────┼──────────┼─────────┼────────┼───────────────┼─────────────┼────────┤
│ 1 │ allocate │ QmZZtzZkfzCWMNrajxBf22q7BC9HzoT5iJUK3S8qA6zNZr │ null │ null │ null │ null │ 0 │ success │ test │ null │ null │ test │
└────┴────────────┴────────────────────────────────────────────────┴──────────────┴────────┴──────┴───────┴──────────┴─────────┴────────┴───────────────┴─────────────┴────────┘

0 comments on commit 6c3a111

Please sign in to comment.