@@ -28,6 +28,10 @@ func (m *mockIntegrationTests) CreateTestData(ctx context.Context, opts integrat
2828 return m .Called (ctx , opts ).Error (0 )
2929}
3030
31+ func (m * mockIntegrationTests ) StartEmbeddedWalletIntegrationTests (ctx context.Context , opts integrationtests.IntegrationTestsOpts ) error {
32+ return m .Called (ctx , opts ).Error (0 )
33+ }
34+
3135func Test_IntegrationTestsCommand_StartIntegrationTestsCommand (t * testing.T ) {
3236 serviceMock := & mockIntegrationTests {}
3337 command := & IntegrationTestsCommand {Service : serviceMock }
@@ -41,7 +45,7 @@ func Test_IntegrationTestsCommand_StartIntegrationTestsCommand(t *testing.T) {
4145 UserEmail : "mockemail@test.com" ,
4246 UserPassword : "mockPassword123!" ,
4347 DisbursedAssetCode : "USDC" ,
44- DisbursetAssetIssuer : "GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVV" ,
48+ DisbursedAssetIssuer : "GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVV" ,
4549 WalletName : "walletTest" ,
4650 DisbursementCSVFilePath : "mockPath" ,
4751 DisbursementCSVFileName : "file.csv" ,
@@ -107,7 +111,7 @@ func Test_IntegrationTestsCommand_CreateIntegrationTestsDataCommand(t *testing.T
107111 integrationTestsOpts := & integrationtests.IntegrationTestsOpts {
108112 DatabaseDSN : "randomDatabaseDSN" ,
109113 DisbursedAssetCode : "USDC" ,
110- DisbursetAssetIssuer : "GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVV" ,
114+ DisbursedAssetIssuer : "GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVV" ,
111115 WalletName : "walletTest" ,
112116 WalletHomepage : "https://www.test_wallet.com" ,
113117 WalletDeepLink : "test-wallet://sdp" ,
@@ -149,3 +153,52 @@ func Test_IntegrationTestsCommand_CreateIntegrationTestsDataCommand(t *testing.T
149153
150154 serviceMock .AssertExpectations (t )
151155}
156+
157+ func Test_IntegrationTestsCommand_StartEmbeddedWalletTestsCommand (t * testing.T ) {
158+ serviceMock := & mockIntegrationTests {}
159+ command := & IntegrationTestsCommand {Service : serviceMock }
160+
161+ parentCmdMock := & cobra.Command {
162+ PersistentPreRun : func (cmd * cobra.Command , args []string ) {},
163+ }
164+
165+ integrationTestsOpts := & integrationtests.IntegrationTestsOpts {
166+ EmbeddedWalletsWasmHash : "0123456789abcdef" ,
167+ RPCUrl : "https://rpc.test" ,
168+ DisbursementCSVFileName : "disbursement.csv" ,
169+ DisbursementCSVFilePath : "/tmp" ,
170+ }
171+
172+ cmd := command .StartEmbeddedWalletTestsCommand (integrationTestsOpts )
173+ parentCmdMock .AddCommand (cmd )
174+
175+ t .Setenv ("ENABLE_EMBEDDED_WALLETS" , "true" )
176+ t .Setenv ("EMBEDDED_WALLETS_WASM_HASH" , "0123456789abcdef" )
177+ t .Setenv ("RPC_URL" , "https://rpc.test" )
178+ t .Setenv ("DISBURSEMENT_CSV_FILE_NAME" , "disbursement.csv" )
179+ t .Setenv ("DISBURSEMENT_CSV_FILE_PATH" , "/tmp" )
180+
181+ parentCmdMock .SetArgs ([]string {
182+ "start-embedded-wallet" ,
183+ })
184+
185+ t .Run ("exit with status 1 when integration tests service fails" , func (t * testing.T ) {
186+ utils .AssertFuncExitsWithFatal (t , func () {
187+ serviceMock .
188+ On ("StartEmbeddedWalletIntegrationTests" , context .Background (), * integrationTestsOpts ).
189+ Return (errors .New ("unexpected error" ))
190+ _ = parentCmdMock .Execute ()
191+ }, "Error starting embedded wallet integration tests: unexpected error" )
192+ })
193+
194+ t .Run ("executes the start embedded wallet integration tests command successfully" , func (t * testing.T ) {
195+ serviceMock .
196+ On ("StartEmbeddedWalletIntegrationTests" , context .Background (), * integrationTestsOpts ).
197+ Return (nil )
198+
199+ err := parentCmdMock .Execute ()
200+ require .NoError (t , err )
201+ })
202+
203+ serviceMock .AssertExpectations (t )
204+ }
0 commit comments