Open lurumad opened 5 years ago
Any news?
@lurumad I'm wading through all different projects involved in hosting Azure WebJobs and Functions and was curious if you managed to host and invoke an http triggered function from a test?
Hi @riezebosch
Actually not, I've only tested triggers from queues, blobs... but I think it could be possible using the host.
Regards!
I managed to create a workaround by setting this environment variable: $"{LanguageWorkerConstants.LanguageWorkersSectionName}:{LanguageWorkerConstants.WorkersDirectorySectionName}"
to some existing directory (like Environment.CurrentDirectory
). This setting is read on this line: https://github.com/Azure/azure-functions-host/blob/acca4b6f6a800218876c4c7692189268ca161987/src/WebJobs.Script/Rpc/Configuration/WorkerConfigFactory.cs#L30
Tried to inject a custom configuration source but up until now it didn't work out for me.
Also checkout the package I'm creating to support this: https://github.com/riezebosch/AzureFunctions.TestHelpers
@pragna, can we check folder existence here:
foreach (var workerDir in Directory.EnumerateDirectories(WorkersDirPath))
It looks like it will resolve the issue.
@lurumad checkout my tiny library and setup on how I got integrations tests running: https://github.com/riezebosch/AzureFunctions.TestHelpers
Hi folks,
I've created an integration test project in order to test my azure functions. I'm using Microsoft.Azure.WebJobs.Script.WebHost package with version 2.0.12303. When I try to run my tests I've received this annoying error:
As you can see in the error it's related with the workers folder that doesn't exists when you install this NuGet package:
C:\Users\lruiz.nuget\packages\microsoft.azure.webjobs.script\2.0.12303\lib\netstandard2.0
If I create this folder my tests passed:
I think is related with this line of code:
https://github.com/Azure/azure-functions-host/blob/acca4b6f6a800218876c4c7692189268ca161987/src/WebJobs.Script/Rpc/Configuration/WorkerConfigFactory.cs#L91
One thing is to check if this folder exists and not enumerate workers directory but I don't know if there are some side effects if this folder doesn't exist. It's very annoying because if another developer pulls the solution and try to run the tests will fails and I have to think if I have to create this folder manually or add some bootstrap to my tests that will make them tightly couple to this path, that's definitively is not a good solution in my opinion.
Regards!