Skip to content

Commit 3681ad6

Browse files
committed
2 parents 2b8c78e + 3f1827e commit 3681ad6

2 files changed

Lines changed: 32 additions & 2 deletions

File tree

scripts/bash/systemd-service-manager/commands/list.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ ssm_cmd_list() {
2727
local service_file
2828
for service_file in "$(ssm_config_root "${project_dir}")"/services/*.conf; do
2929
[[ -f "${service_file}" ]] || continue
30-
printf '- %s\n' "$(basename "${service_file}" .conf)"
30+
printf -- '- %s\n' "$(basename "${service_file}" .conf)"
3131
done
3232

3333
printf 'Timers\n'
3434
local timer_file
3535
for timer_file in "$(ssm_config_root "${project_dir}")"/timers/*.conf; do
3636
[[ -f "${timer_file}" ]] || continue
37-
printf '- %s\n' "$(basename "${timer_file}" .conf)"
37+
printf -- '- %s\n' "$(basename "${timer_file}" .conf)"
3838
done
3939
}

scripts/bash/systemd-service-manager/tests/manager-cli.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { afterEach, describe, expect, it } from 'vitest'
2+
import fs from 'node:fs'
3+
import path from 'node:path'
24
import {
35
cleanupWorkspace,
46
createWorkspace,
@@ -50,4 +52,32 @@ describe('systemd service manager cli', () => {
5052
expect(result.exitCode).not.toBe(0)
5153
expect(result.stderr + result.stdout).toContain('Unknown command')
5254
})
55+
56+
it('lists declared services and timers from the built binary', async () => {
57+
const workspace = createWorkspace()
58+
workspaces.push(workspace)
59+
60+
const build = await runBuild(workspace)
61+
expect(build.exitCode).toBe(0)
62+
63+
const projectRoot = path.join(workspace.root, 'demo-app')
64+
fs.cpSync(
65+
path.join(workspace.managerHome, 'tests', 'fixtures', 'project-basic'),
66+
projectRoot,
67+
{ recursive: true },
68+
)
69+
70+
const result = await runBuilt(workspace, 'bin', [
71+
'list',
72+
'--project',
73+
projectRoot,
74+
])
75+
76+
expect(result.exitCode).toBe(0)
77+
expect(result.stdout).toContain('Services')
78+
expect(result.stdout).toContain('- api')
79+
expect(result.stdout).toContain('Timers')
80+
expect(result.stdout).toContain('- cleanup')
81+
expect(result.stdout).toContain('- restart-api')
82+
})
5383
})

0 commit comments

Comments
 (0)