18
18
/* eslint-disable @typescript-eslint/no-explicit-any */
19
19
/* eslint-disable @typescript-eslint/explicit-function-return-type */
20
20
21
- import type { Extension } from '@podman-desktop/api' ;
21
+ import type { Extension , ProviderContainerConnection } from '@podman-desktop/api' ;
22
22
import { extensions } from '@podman-desktop/api' ;
23
23
import type { PodmanExtensionApi } from '@podman-desktop/podman-extension-api' ;
24
24
import { beforeEach , expect , test , vi } from 'vitest' ;
@@ -59,9 +59,18 @@ beforeEach(() => {
59
59
) ;
60
60
} ) ;
61
61
62
+ const connectionName = 'machine1' ;
63
+
64
+ const connection = {
65
+ connection : {
66
+ name : connectionName ,
67
+ } ,
68
+ providerId : 'id1' ,
69
+ } as ProviderContainerConnection ;
70
+
62
71
test ( 'runSubscriptionManager returns 0 when it is installed' , async ( ) => {
63
72
execMock . mockResolvedValue ( runResult ) ;
64
- const result = await runSubscriptionManager ( 'machine1' ) ;
73
+ const result = await runSubscriptionManager ( connection ) ;
65
74
expect ( result ) . toBe ( 0 ) ;
66
75
} ) ;
67
76
@@ -72,15 +81,15 @@ test('runSubscriptionManager returns 1 when it is not installed', async () => {
72
81
stderr : 'stderr output' ,
73
82
toString : ( ) => 'error message' ,
74
83
} ) ;
75
- const result = await runSubscriptionManager ( 'machine1' ) ;
84
+ const result = await runSubscriptionManager ( connection ) ;
76
85
expect ( result ) . toBe ( 1 ) ;
77
86
} ) ;
78
87
79
88
test ( 'runRpmInstallSubscription manager returns 0 when successful' , async ( ) => {
80
89
execMock . mockResolvedValue ( runResult ) ;
81
- const result = await runRpmInstallSubscriptionManager ( 'machine1' ) ;
90
+ const result = await runRpmInstallSubscriptionManager ( connection ) ;
82
91
expect ( result ) . toBe ( runResult ) ;
83
- expect ( execMock ) . toBeCalledWith ( PODMAN_COMMANDS . rpmInstallSm ( 'machine1' ) ) ;
92
+ expect ( execMock ) . toBeCalledWith ( PODMAN_COMMANDS . rpmInstallSm ( connectionName ) , { connection } ) ;
84
93
} ) ;
85
94
86
95
test ( 'runRpmInstallSubscription manager returns none 0 error code when failed and send telemetry' , async ( ) => {
@@ -90,7 +99,7 @@ test('runRpmInstallSubscription manager returns none 0 error code when failed an
90
99
} ) ;
91
100
const consoleError = vi . spyOn ( console , 'error' ) ;
92
101
let error : unknown ;
93
- await runRpmInstallSubscriptionManager ( 'machine1' ) . catch ( ( err : unknown ) => {
102
+ await runRpmInstallSubscriptionManager ( connection ) . catch ( ( err : unknown ) => {
94
103
error = err ;
95
104
} ) ;
96
105
expect ( String ( error ) ) . toBe ( String ( runError ) ) ;
@@ -105,7 +114,7 @@ test('runRpmInstallSubscription manager returns none 0 error code when failed an
105
114
106
115
test ( 'runSubscriptionManagerActivationStatus returns 0 when it has subscription activated' , async ( ) => {
107
116
execMock . mockResolvedValue ( runResult ) ;
108
- const result = await runSubscriptionManagerActivationStatus ( 'machine1' ) ;
117
+ const result = await runSubscriptionManagerActivationStatus ( connection ) ;
109
118
expect ( result ) . toBe ( 0 ) ;
110
119
} ) ;
111
120
@@ -116,15 +125,17 @@ test('runSubscriptionManagerActivationStatus returns 1 when it has no active sub
116
125
stderr : 'stderr output' ,
117
126
toString : ( ) => 'error message' ,
118
127
} ) ;
119
- const result = await runSubscriptionManagerActivationStatus ( 'machine1' ) ;
128
+ const result = await runSubscriptionManagerActivationStatus ( connection ) ;
120
129
expect ( result ) . toBe ( 1 ) ;
121
130
} ) ;
122
131
123
132
test ( 'runSubscriptionManagerRegister returns 0 when successful' , async ( ) => {
124
133
execMock . mockResolvedValue ( runResult ) ;
125
- const result = await runSubscriptionManagerRegister ( 'machine1' , 'activation-key-name' , 'orgId' ) ;
134
+ const result = await runSubscriptionManagerRegister ( connection , 'activation-key-name' , 'orgId' ) ;
126
135
expect ( result ) . toBe ( runResult ) ;
127
- expect ( execMock ) . toBeCalledWith ( PODMAN_COMMANDS . smActivateSubs ( 'machine1' , 'activation-key-name' , 'orgId' ) ) ;
136
+ expect ( execMock ) . toBeCalledWith ( PODMAN_COMMANDS . smActivateSubs ( 'machine1' , 'activation-key-name' , 'orgId' ) , {
137
+ connection,
138
+ } ) ;
128
139
} ) ;
129
140
130
141
test ( 'runSubscriptionManagerRegister manager returns none 0 error code when failed and send telemetry' , async ( ) => {
@@ -134,7 +145,7 @@ test('runSubscriptionManagerRegister manager returns none 0 error code when fail
134
145
} ) ;
135
146
const consoleError = vi . spyOn ( console , 'error' ) ;
136
147
let error : unknown ;
137
- await runSubscriptionManagerRegister ( 'machine1' , 'activation-key-name' , 'orgId' ) . catch ( ( err : unknown ) => {
148
+ await runSubscriptionManagerRegister ( connection , 'activation-key-name' , 'orgId' ) . catch ( ( err : unknown ) => {
138
149
error = err ;
139
150
} ) ;
140
151
expect ( String ( error ) ) . toBe ( String ( runError ) ) ;
@@ -149,9 +160,9 @@ test('runSubscriptionManagerRegister manager returns none 0 error code when fail
149
160
150
161
test ( 'runCreateFactsFile returns 0 when successful' , async ( ) => {
151
162
execMock . mockResolvedValue ( runResult ) ;
152
- const result = await runCreateFactsFile ( 'machine1' , '{"field":"value"}' ) ;
163
+ const result = await runCreateFactsFile ( connection , '{"field":"value"}' ) ;
153
164
expect ( result ) . toBe ( runResult ) ;
154
- expect ( execMock ) . toBeCalledWith ( PODMAN_COMMANDS . createFactFile ( 'machine1' , '{"field":"value"}' ) ) ;
165
+ expect ( execMock ) . toBeCalledWith ( PODMAN_COMMANDS . createFactFile ( connectionName , '{"field":"value"}' ) , { connection } ) ;
155
166
} ) ;
156
167
157
168
test ( 'runCreateFactsFile manager returns none 0 error code when failed and send telemetry' , async ( ) => {
@@ -161,7 +172,7 @@ test('runCreateFactsFile manager returns none 0 error code when failed and send
161
172
} ) ;
162
173
const consoleError = vi . spyOn ( console , 'error' ) ;
163
174
let error : unknown ;
164
- await runCreateFactsFile ( 'machine1' , '{"field":"value"}' ) . catch ( ( err : unknown ) => {
175
+ await runCreateFactsFile ( connection , '{"field":"value"}' ) . catch ( ( err : unknown ) => {
165
176
error = err ;
166
177
} ) ;
167
178
expect ( String ( error ) ) . toBe ( String ( runError ) ) ;
@@ -176,9 +187,9 @@ test('runCreateFactsFile manager returns none 0 error code when failed and send
176
187
177
188
test ( 'runStopPodmanMachine returns 0 when successful' , async ( ) => {
178
189
execMock . mockResolvedValue ( runResult ) ;
179
- const result = await runStopPodmanMachine ( 'machine1' ) ;
190
+ const result = await runStopPodmanMachine ( connection ) ;
180
191
expect ( result ) . toBe ( runResult ) ;
181
- expect ( execMock ) . toBeCalledWith ( PODMAN_COMMANDS . machineStop ( 'machine1' ) ) ;
192
+ expect ( execMock ) . toBeCalledWith ( PODMAN_COMMANDS . machineStop ( connectionName ) , { connection } ) ;
182
193
} ) ;
183
194
184
195
test ( 'runStopPodmanMachine manager returns none 0 error code when failed and send telemetry' , async ( ) => {
@@ -187,7 +198,7 @@ test('runStopPodmanMachine manager returns none 0 error code when failed and sen
187
198
const consoleError = vi . spyOn ( console , 'error' ) ;
188
199
189
200
let error : unknown ;
190
- await runStopPodmanMachine ( 'machine1' ) . catch ( ( err : unknown ) => {
201
+ await runStopPodmanMachine ( connection ) . catch ( ( err : unknown ) => {
191
202
error = err ;
192
203
} ) ;
193
204
expect ( String ( error ) ) . toBe ( String ( runError ) ) ;
@@ -202,9 +213,9 @@ test('runStopPodmanMachine manager returns none 0 error code when failed and sen
202
213
203
214
test ( 'runStartPodmanMachine returns 0 when successful' , async ( ) => {
204
215
execMock . mockResolvedValue ( runResult ) ;
205
- const result = await runStartPodmanMachine ( 'machine1' ) ;
216
+ const result = await runStartPodmanMachine ( connection ) ;
206
217
expect ( result ) . toBe ( runResult ) ;
207
- expect ( execMock ) . toBeCalledWith ( PODMAN_COMMANDS . machineStart ( 'machine1' ) ) ;
218
+ expect ( execMock ) . toBeCalledWith ( PODMAN_COMMANDS . machineStart ( connectionName ) , { connection } ) ;
208
219
} ) ;
209
220
210
221
test ( 'runStartPodmanMachine manager returns none 0 error code when failed and send telemetry' , async ( ) => {
@@ -214,7 +225,7 @@ test('runStartPodmanMachine manager returns none 0 error code when failed and se
214
225
} ) ;
215
226
const consoleError = vi . spyOn ( console , 'error' ) ;
216
227
let error : unknown ;
217
- await runStartPodmanMachine ( 'machine1' ) . catch ( ( err : unknown ) => {
228
+ await runStartPodmanMachine ( connection ) . catch ( ( err : unknown ) => {
218
229
error = err ;
219
230
} ) ;
220
231
expect ( String ( error ) ) . toBe ( String ( runError ) ) ;
0 commit comments