@@ -5085,6 +5085,58 @@ Error code: Wsl/InstallDistro/WSL_E_DISTRO_NOT_FOUND\r\n",
50855085 L" " );
50865086 }
50875087
5088+ // Validate that a distribution isn't downloaded if its name is already in use.
5089+ {
5090+ auto manifest = std::format (
5091+ R"( {{
5092+ "ModernDistributions": {{
5093+ "debian": [
5094+ {{
5095+ "Name": "{}",
5096+ "FriendlyName": "DebianFriendlyName",
5097+ "Amd64Url": {{
5098+ "Url": "file://doesnotexist",
5099+ "Sha256": ""
5100+ }}
5101+ }},
5102+ {{
5103+ "Name": "dummy",
5104+ "FriendlyName": "dummy",
5105+ "Amd64Url": {{
5106+ "Url": "file://doesnotexist",
5107+ "Sha256": ""
5108+ }}
5109+ }}
5110+ ]
5111+ }}
5112+ }})" ,
5113+ LXSS_DISTRO_NAME_TEST);
5114+
5115+ auto restore = SetManifest (manifest);
5116+
5117+ {
5118+ auto [out, err] = LxsstuLaunchWslAndCaptureOutput (std::format (L" --install {}" , LXSS_DISTRO_NAME_TEST_L), -1 );
5119+
5120+ VERIFY_ARE_EQUAL (
5121+ out,
5122+ L" A distribution with the supplied name already exists. Use --name to chose a different name.\r\n "
5123+ L" Error code: Wsl/InstallDistro/ERROR_ALREADY_EXISTS\r\n " );
5124+
5125+ VERIFY_ARE_EQUAL (err, L" " );
5126+ }
5127+
5128+ {
5129+ auto [out, err] = LxsstuLaunchWslAndCaptureOutput (std::format (L" --install dummy --name {}" , LXSS_DISTRO_NAME_TEST_L), -1 );
5130+
5131+ VERIFY_ARE_EQUAL (
5132+ out,
5133+ L" A distribution with the supplied name already exists. Use --name to chose a different name.\r\n "
5134+ L" Error code: Wsl/InstallDistro/ERROR_ALREADY_EXISTS\r\n " );
5135+
5136+ VERIFY_ARE_EQUAL (err, L" " );
5137+ }
5138+ }
5139+
50885140 // Validate handling of case where no default install distro is configured.
50895141 {
50905142 auto manifest =
0 commit comments