@@ -435,6 +435,33 @@ TEST_CASE("ListFlow_JsonOutputBadSource", "[ListFlow][workflow]")
435435 REQUIRE (context.GetTerminationHR () == APPINSTALLER_CLI_ERROR_SOURCE_NAME_DOES_NOT_EXIST );
436436}
437437
438+ TEST_CASE (" ListFlow_JsonOutputStopsCompositeAfterInstalledSourceFailure" , " [ListFlow][workflow]" )
439+ {
440+ std::ostringstream listOutput;
441+ TestContext context{ listOutput, std::cin };
442+ auto previousThreadGlobals = context.SetForCurrentThread ();
443+ context.Args .AddArg (Execution::Args::Type::OutputFormat, " json" sv);
444+ Workflow::SetJsonOutputChannel (context);
445+
446+ auto availableSource = AppInstaller::Repository::Source{ CreateTestSource ({ TSR ::TestInstaller_Exe }) };
447+ context.Add <Execution::Data::Source>(availableSource);
448+ context.Override ({ " OpenPredefinedSource" , [](TestContext& context)
449+ {
450+ context.Reporter .Json () << R"( {"packages":[],"truncated":false,"sourceFailures":[],"error":{"code":"0x8a15000e","message":"Failed to open source."}})" << std::endl;
451+ context.SetTerminationHR (APPINSTALLER_CLI_ERROR_SOURCE_OPEN_FAILED );
452+ } });
453+
454+ context << Workflow::OpenCompositeSource (AppInstaller::Repository::PredefinedSource::Installed);
455+ INFO (listOutput.str ());
456+
457+ Json::Value json = ConvertToJson (listOutput.str ());
458+ REQUIRE (json[" packages" ].isArray ());
459+ REQUIRE (json[" packages" ].empty ());
460+ REQUIRE (json[" error" ][" code" ].asString () == " 0x8a15000e" );
461+ REQUIRE (context.GetTerminationHR () == APPINSTALLER_CLI_ERROR_SOURCE_OPEN_FAILED );
462+ REQUIRE_FALSE (context.Get <Execution::Data::Source>().IsComposite ());
463+ }
464+
438465TEST_CASE (" UpdateFlow_ListJsonOutput" , " [UpdateFlow][workflow]" )
439466{
440467 std::ostringstream updateOutput;
0 commit comments