Skip to content

Commit 9145339

Browse files
authored
fix(commerce): always pass all arguments to commerce command API. fixes #552
1 parent 7b44249 commit 9145339

File tree

6 files changed

+15
-18
lines changed

6 files changed

+15
-18
lines changed

src/commands/cloudmanager/commerce/bin-magento/cache/clean.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,12 @@ class CacheCleanCommand extends BaseCommerceCliCommand {
2121
const { flags, argv } = this.parse(CacheCleanCommand)
2222

2323
const programId = getProgramId(flags)
24-
const cacheTypes = argv.slice(1)
2524

2625
const result = await this.runSync(programId, flags.environmentId,
2726
{
2827
type: 'bin/magento',
2928
command: 'cache:clean',
30-
options: ['-n', ...cacheTypes, ...getFormattedFlags(flags, CacheCleanCommand)],
29+
options: ['-n', ...argv, ...getFormattedFlags(flags, CacheCleanCommand)],
3130
},
3231
1000, 'cache:clean')
3332

src/commands/cloudmanager/commerce/bin-magento/cache/flush.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,12 @@ class CacheFlushCommand extends BaseCommerceCliCommand {
2121
const { flags, argv } = this.parse(CacheFlushCommand)
2222

2323
const programId = getProgramId(flags)
24-
const cacheTypes = argv.slice(1)
2524

2625
const result = await this.runSync(programId, flags.environmentId,
2726
{
2827
type: 'bin/magento',
2928
command: 'cache:flush',
30-
options: ['-n', ...cacheTypes, ...getFormattedFlags(flags, CacheFlushCommand)],
29+
options: ['-n', ...argv, ...getFormattedFlags(flags, CacheFlushCommand)],
3130
},
3231
1000, 'cache:flush')
3332

src/commands/cloudmanager/commerce/bin-magento/indexer/reindex.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,12 @@ class IndexerReindexCommand extends BaseCommerceCliCommand {
2121
const { flags, argv } = this.parse(IndexerReindexCommand)
2222

2323
const programId = getProgramId(flags)
24-
const indexTypes = argv.slice(1)
2524

2625
const result = await this.runSync(programId, flags.environmentId,
2726
{
2827
type: 'bin/magento',
2928
command: 'indexer:reindex',
30-
options: ['-n', ...indexTypes, ...getFormattedFlags(flags, IndexerReindexCommand)],
29+
options: ['-n', ...argv, ...getFormattedFlags(flags, IndexerReindexCommand)],
3130
},
3231
1000, 'indexer:reindex')
3332

test/commands/commerce/bin-magento/cache/clean.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ test('cache:clean - missing arg', async () => {
3838
await expect(runResult).rejects.toThrow(/^Missing required flag/)
3939
})
4040

41-
test('maintenance:status - missing config', async () => {
41+
test('cache:clean - missing config', async () => {
4242
expect.assertions(2)
4343

4444
const runResult = run(['--programId', '5', '--environmentId', '10'])
4545
await expect(runResult instanceof Promise).toBeTruthy()
4646
await expect(runResult).rejects.toThrow('[CloudManagerCLI:NO_IMS_CONTEXT] Unable to find IMS context aio-cli-plugin-cloudmanager.')
4747
})
4848

49-
test('maintenance:status', async () => {
49+
test('cache:clean', async () => {
5050
let counter = 0
5151
setCurrentOrgId('good')
5252
mockSdk.postCommerceCommandExecution = jest.fn(() =>
@@ -75,7 +75,7 @@ test('maintenance:status', async () => {
7575

7676
expect.assertions(11)
7777

78-
const runResult = run(['--programId', '5', '--environmentId', '10', '-V', '--ansi'])
78+
const runResult = run(['--programId', '5', '--environmentId', '10', '-V', '--ansi', 'cacheType1', 'cacheType2'])
7979
await expect(runResult instanceof Promise).toBeTruthy()
8080
await runResult
8181
await expect(init.mock.calls.length).toEqual(1)
@@ -89,7 +89,7 @@ test('maintenance:status', async () => {
8989
await expect(mockSdk.postCommerceCommandExecution).toHaveBeenCalledWith('5', '10', {
9090
type: 'bin/magento',
9191
command: 'cache:clean',
92-
options: ['-n', '--version', '--ansi'],
92+
options: ['-n', 'cacheType1', 'cacheType2', '--version', '--ansi'],
9393
})
9494
await expect(mockSdk.getCommerceCommandExecution).toHaveBeenCalledWith('5', '10', '5000')
9595
await expect(mockSdk.getCommerceCommandExecution).toHaveBeenCalledTimes(3)

test/commands/commerce/bin-magento/cache/flush.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ test('cache:flush - missing environemtId', async () => {
3838
await expect(runResult).rejects.toThrow(/^Missing required flag/)
3939
})
4040

41-
test('maintenance:status - missing config', async () => {
41+
test('cache:flush - missing config', async () => {
4242
expect.assertions(2)
4343

4444
const runResult = run(['--programId', '5', '--environmentId', '10'])
4545
await expect(runResult instanceof Promise).toBeTruthy()
4646
await expect(runResult).rejects.toThrow('[CloudManagerCLI:NO_IMS_CONTEXT] Unable to find IMS context aio-cli-plugin-cloudmanager.')
4747
})
4848

49-
test('maintenance:status', async () => {
49+
test('cache:flush', async () => {
5050
let counter = 0
5151
setCurrentOrgId('good')
5252
mockSdk.postCommerceCommandExecution = jest.fn(() =>
@@ -75,7 +75,7 @@ test('maintenance:status', async () => {
7575

7676
expect.assertions(11)
7777

78-
const runResult = run(['--programId', '5', '--environmentId', '10', '--no-ansi'])
78+
const runResult = run(['--programId', '5', '--environmentId', '10', '--no-ansi', 'cacheType1', 'cacheType2'])
7979
await expect(runResult instanceof Promise).toBeTruthy()
8080
await runResult
8181
await expect(init.mock.calls.length).toEqual(1)
@@ -89,7 +89,7 @@ test('maintenance:status', async () => {
8989
await expect(mockSdk.postCommerceCommandExecution).toHaveBeenCalledWith('5', '10', {
9090
type: 'bin/magento',
9191
command: 'cache:flush',
92-
options: ['-n', '--no-ansi'],
92+
options: ['-n', 'cacheType1', 'cacheType2', '--no-ansi'],
9393
})
9494
await expect(mockSdk.getCommerceCommandExecution).toHaveBeenCalledWith('5', '10', '5000')
9595
await expect(mockSdk.getCommerceCommandExecution).toHaveBeenCalledTimes(3)

test/commands/commerce/bin-magento/indexer/reindex.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ test('indexer:reindex - missing arg', async () => {
3838
await expect(runResult).rejects.toThrow(/^Missing required flag/)
3939
})
4040

41-
test('maintenance:status - missing config', async () => {
41+
test('indexer:reindex - missing config', async () => {
4242
expect.assertions(2)
4343

4444
const runResult = run(['--programId', '5', '--environmentId', '10'])
4545
await expect(runResult instanceof Promise).toBeTruthy()
4646
await expect(runResult).rejects.toThrow('[CloudManagerCLI:NO_IMS_CONTEXT] Unable to find IMS context aio-cli-plugin-cloudmanager.')
4747
})
4848

49-
test('maintenance:status', async () => {
49+
test('indexer:reindex', async () => {
5050
let counter = 0
5151
setCurrentOrgId('good')
5252
mockSdk.postCommerceCommandExecution = jest.fn(() =>
@@ -75,7 +75,7 @@ test('maintenance:status', async () => {
7575

7676
expect.assertions(11)
7777

78-
const runResult = run(['--programId', '5', '--environmentId', '10'])
78+
const runResult = run(['--programId', '5', '--environmentId', '10', 'index1', 'index2'])
7979
await expect(runResult instanceof Promise).toBeTruthy()
8080
await runResult
8181
await expect(init.mock.calls.length).toEqual(1)
@@ -89,7 +89,7 @@ test('maintenance:status', async () => {
8989
await expect(mockSdk.postCommerceCommandExecution).toHaveBeenCalledWith('5', '10', {
9090
type: 'bin/magento',
9191
command: 'indexer:reindex',
92-
options: ['-n'],
92+
options: ['-n', 'index1', 'index2'],
9393
})
9494
await expect(mockSdk.getCommerceCommandExecution).toHaveBeenCalledWith('5', '10', '5000')
9595
await expect(mockSdk.getCommerceCommandExecution).toHaveBeenCalledTimes(3)

0 commit comments

Comments
 (0)