https://pulumi.com logo
#dotnet
Title
# dotnet
b

breezy-salesmen-85534

01/27/2021, 9:09 AM
Copy code
Vipps.Vce.Core.Tests.K8s.KubernetesClusterTests.Test_Create_Cluster

Pulumi.RunException: Running program '/Applications/Rider.app/Contents/lib/ReSharperHost/TestRunner/netcoreapp2.0/ReSharperTestRunner64.dll' failed wi...

Pulumi.RunException
Running program '/Applications/Rider.app/Contents/lib/ReSharperHost/TestRunner/netcoreapp2.0/ReSharperTestRunner64.dll' failed with an unhandled exception:
System.NullReferenceException: Object reference not set to an instance of an object.
   at Pulumi.Testing.MockMonitor.SerializeToDictionary(Object o)
   at Pulumi.Testing.MockMonitor.RegisterResourceAsync(Resource resource, RegisterResourceRequest request)
   at Pulumi.Deployment.RegisterResourceAsync(Resource resource, Boolean remote, Func`2 newDependency, ResourceArgs args, ResourceOptions options)
   at Pulumi.Deployment.ReadOrRegisterResourceAsync(Resource resource, Boolean remote, Func`2 newDependency, ResourceArgs args, ResourceOptions options)
   at Pulumi.Deployment.CompleteResourceAsync(Resource resource, Boolean remote, Func`2 newDependency, ResourceArgs args, ResourceOptions options, ImmutableDictionary`2 completionSources)
   at Pulumi.Output`1.GetValueAsync()
   at Pulumi.Deployment.Logger.TryGetResourceUrnAsync(Resource resource)
   at Pulumi.Deployment.Runner.<>c__DisplayClass9_0.<<WhileRunningAsync>g__HandleCompletion|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Pulumi.Deployment.Runner.WhileRunningAsync()
   at Pulumi.Deployment.TestAsync(IMocks mocks, Func`2 runAsync, TestOptions options)
   at Vipps.Vce.Core.Tests.K8s.KubernetesClusterTests.CreateCluster() in /Users/andreas.dreyer.hysing/code/vce/src/Core.Tests/K8s/KubernetesClusterTests.cs:line 39
   at Vipps.Vce.Core.Tests.K8s.KubernetesClusterTests.Test_Create_Cluster() in /Users/andreas.dreyer.hysing/code/vce/src/Core.Tests/K8s/KubernetesClusterTests.cs:line 48
   at Xunit.Sdk.TestInvoker`1.<>c__DisplayClass48_1.<<InvokeTestMethodAsync>b__1>d.MoveNext() in C:\Dev\xunit\xunit\src\xunit.execution\Sdk\Frameworks\Runners\TestInvoker.cs:line 264
--- End of stack trace from previous location where exception was thrown ---
   at Xunit.Sdk.ExecutionTimer.AggregateAsync(Func`1 asyncAction) in C:\Dev\xunit\xunit\src\xunit.execution\Sdk\Frameworks\ExecutionTimer.cs:line 48
   at Xunit.Sdk.ExceptionAggregator.RunAsync(Func`1 code) in C:\Dev\xunit\xunit\src\xunit.core\Sdk\ExceptionAggregator.cs:line 90
t

tall-librarian-49374

01/27/2021, 9:27 AM
I guess your mocks return null which causes this error. You’d have to actually implement
IMocks
.
b

breezy-salesmen-85534

01/27/2021, 9:32 AM
thank you for a quick reply. I will try that.
I implemented IMocks, as you said. It worked. Now that I want to test kubernetes namspaces (only) I would have to create a separate test stack with kubernetes and kubernetese namspaces. It feels a bit clumbersome, but it works. I can live with that. To anyone else reading this. the solution here is to set up IMocks with
Copy code
var mocks = new Mock<IMocks>();

            mocks.Setup(m => m.NewResourceAsync(It.IsAny<string>(), It.IsAny<string>(),
                    It.IsAny<ImmutableDictionary<string, object>>(), It.IsAny<string>(), It.IsAny<string>()))
                .ReturnsAsync((string type, string name, ImmutableDictionary<string, object> inputs, string provider,
                    string id) => (name + "_id", inputs));
🙂