Skip to content

Commit b9e470f

Browse files
Copilotvobu
andcommitted
fix: address code review feedback
- Fix type checking in runtime tests for activeProfile and activeTenant - Update outputMode test to not set value before testing - Improve comment for saveSessionState function Co-authored-by: vobu <6573426+vobu@users.noreply.github.com>
1 parent 64d3c35 commit b9e470f

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ export function loadSessionState(): SessionState {
207207

208208
/**
209209
* Save session state to c8ctl runtime object
210-
* Note: Session state is no longer persisted to disk
210+
* This function updates the c8ctl runtime object properties with the provided session state
211211
*/
212212
export function saveSessionState(state: SessionState): void {
213213
c8ctl.activeProfile = state.activeProfile;

tests/unit/runtime.test.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@ describe('c8ctl Runtime', () => {
3939
});
4040

4141
test('should have activeProfile property with undefined default', () => {
42-
// Note: This test assumes a fresh runtime state
43-
// In a real scenario, the property may have been set by previous tests
44-
assert.strictEqual(typeof c8ctl.activeProfile, 'string' as any || 'undefined', 'activeProfile is string or undefined');
42+
// Note: This property may have been set by previous tests in the same process
43+
// We just verify it's the correct type
44+
const profile = c8ctl.activeProfile;
45+
assert.ok(profile === undefined || typeof profile === 'string', 'activeProfile is undefined or string');
4546
});
4647

4748
test('should be able to set and get activeProfile', () => {
@@ -54,7 +55,10 @@ describe('c8ctl Runtime', () => {
5455
});
5556

5657
test('should have activeTenant property with undefined default', () => {
57-
assert.strictEqual(typeof c8ctl.activeTenant, 'string' as any || 'undefined', 'activeTenant is string or undefined');
58+
// Note: This property may have been set by previous tests in the same process
59+
// We just verify it's the correct type
60+
const tenant = c8ctl.activeTenant;
61+
assert.ok(tenant === undefined || typeof tenant === 'string', 'activeTenant is undefined or string');
5862
});
5963

6064
test('should be able to set and get activeTenant', () => {
@@ -66,10 +70,9 @@ describe('c8ctl Runtime', () => {
6670
c8ctl.activeTenant = undefined;
6771
});
6872

69-
test('should have outputMode property with text default', () => {
70-
// Reset to default
71-
c8ctl.outputMode = 'text';
72-
assert.strictEqual(c8ctl.outputMode, 'text', 'outputMode defaults to text');
73+
test('should have outputMode property', () => {
74+
// Verify outputMode is always set to either 'text' or 'json'
75+
assert.ok(c8ctl.outputMode === 'text' || c8ctl.outputMode === 'json', 'outputMode is text or json');
7376
});
7477

7578
test('should be able to set and get outputMode', () => {

0 commit comments

Comments
 (0)