Skip to content

Commit

Permalink
V3 - .NET User Experience Bug Fix (#3442)
Browse files Browse the repository at this point in the history
* UX fix

* Increasing timeout.

* More timeouts

* bugggg!
  • Loading branch information
khkh-ms authored Sep 1, 2023
1 parent ad67847 commit 097a5ef
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ public async override Task RunAsync()
{
SelectionMenuHelper.DisplaySelectionWizardPrompt("template");
TemplateName = TemplateName ?? SelectionMenuHelper.DisplaySelectionWizard(DotnetHelpers.GetTemplates(workerRuntime));
TemplateName = GetTemplateShortName(TemplateName);

ColoredConsole.Write("Function name: ");
FunctionName = FunctionName ?? Console.ReadLine();
ColoredConsole.WriteLine(FunctionName);
Expand Down Expand Up @@ -263,5 +265,24 @@ private void PerformPostDeployTasks(string functionName, string language)
FileSystemHelpers.WriteAllTextToFile(funcJsonFile, JsonConvert.SerializeObject(funcObj, Formatting.Indented));
}
}

private static string GetTemplateShortName(string templateName) => templateName.ToLowerInvariant() switch
{
"blobtrigger" => "blob",
"cosmosdbtrigger" => "cosmos",
"durablefunctionsorchestration" => "durable",
"eventgridtrigger" => "eventgrid",
"eventhubtrigger" => "eventhub",
"httptrigger" => "http",
"iothubtrigger" => "iothub",
"kafkatrigger" => "kafka",
"kafkaoutput" => "kafkao",
"queuetrigger" => "queue",
"sendgrid" => "sendgrid",
"servicebusqueuetrigger" => "squeue",
"servicebustopictrigger" => "stopic",
"timertrigger" => "timer",
_ => templateName
};
}
}
9 changes: 8 additions & 1 deletion test/Azure.Functions.Cli.Tests/E2E/StartTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ await CliTester.Run(new RunConfiguration[]
string hostJsonContent = "{\"version\": \"2.0\",\"logging\": {\"logLevel\": {\"Default\": \"Debug\"}}}";
await File.WriteAllTextAsync(filePath, hostJsonContent);
},
CommandTimeout = TimeSpan.FromSeconds(120),
},
new RunConfiguration
{
Expand Down Expand Up @@ -171,6 +172,7 @@ await CliTester.Run(new RunConfiguration[]
string hostJsonContent = "{\"version\": \"2.0\",\"logging\": {\"logLevel\": {\"Default\": \"None\", \"Host.Startup\": \"Information\"}}}";
await File.WriteAllTextAsync(filePath, hostJsonContent);
},
CommandTimeout = TimeSpan.FromSeconds(120)
},
new RunConfiguration
{
Expand Down Expand Up @@ -216,7 +218,7 @@ await CliTester.Run(new RunConfiguration[]
var filePath = Path.Combine(workingDir, "host.json");
string hostJsonContent = "{\"version\": \"2.0\",\"logging\": {\"logLevel\": {\"Default\": \"None\"}}}";
await File.WriteAllTextAsync(filePath, hostJsonContent);
},
}
},
new RunConfiguration
{
Expand Down Expand Up @@ -334,6 +336,7 @@ await CliTester.Run(new RunConfiguration[]
string hostJsonContent = "{ \"version\": \"2.0\", \"extensionBundle\": { \"id\": \"Microsoft.Azure.Functions.ExtensionBundle\", \"version\": \"[2.*, 3.0.0)\" }}";
await File.WriteAllTextAsync(filePath, hostJsonContent);
},
CommandTimeout = TimeSpan.FromSeconds(120),
},
new RunConfiguration
{
Expand Down Expand Up @@ -368,6 +371,7 @@ await CliTester.Run(new RunConfiguration[]
var hostJsonPath = Path.Combine(workingDir, "host.json");
File.Delete(hostJsonPath);
},
CommandTimeout = TimeSpan.FromSeconds(120),
},
new RunConfiguration
{
Expand Down Expand Up @@ -542,6 +546,7 @@ await CliTester.Run(new RunConfiguration[]
"new --template http --name http1",
"new --template queue --name queue1"
},
CommandTimeout = TimeSpan.FromSeconds(120),
},
new RunConfiguration
{
Expand Down Expand Up @@ -621,6 +626,7 @@ await CliTester.Run(new RunConfiguration[]
"new --template \"Http trigger\" --name http1",
"new --template \"Queue trigger\" --name queue1"
},
CommandTimeout = TimeSpan.FromSeconds(120),
},
new RunConfiguration
{
Expand Down Expand Up @@ -687,6 +693,7 @@ await CliTester.Run(new RunConfiguration[]
"new --template \"Http trigger\" --name http1",
"new --template \"Queue trigger\" --name queue1"
},
CommandTimeout = TimeSpan.FromSeconds(120),
},
new RunConfiguration
{
Expand Down

0 comments on commit 097a5ef

Please sign in to comment.