Dynamic provider test

This commit is contained in:
Fraser Waters 2021-11-09 16:01:23 +00:00
parent d7ec7ce06c
commit e20ffbebba
6 changed files with 66 additions and 0 deletions

View file

@ -0,0 +1,3 @@
/.pulumi/
[Bb]in/
[Oo]bj/

View file

@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
</Project>

View file

@ -0,0 +1,32 @@
// Copyright 2016-2019, Pulumi Corporation. All rights reserved.
using System.Threading.Tasks;
using Pulumi;
//import binascii
//import os
//from pulumi import ComponentResource, export
//from pulumi.dynamic import Resource, ResourceProvider, CreateResult//
//class RandomResourceProvider(ResourceProvider):
// def create(self, props):
// val = binascii.b2a_hex(os.urandom(15)).decode("ascii")
// return CreateResult(val, { "val": val })//
//class Random(Resource):
// val: str
// def __init__(self, name, opts = None):
// super().__init__(RandomResourceProvider(), name, {"val": ""}, opts)//
//r = Random("foo")//
//export("random_id", r.id)
//export("random_val", r.val)
class Program
{
static Task<int> Main(string[] args)
{
return Deployment.RunAsync(() => {});
}
}

View file

@ -0,0 +1,3 @@
name: dynamic_dotnet
description: A simple dotnet program that uses dynamic providers.
runtime: dotnet

View file

@ -0,0 +1 @@
Intentionally make no changes.

View file

@ -591,3 +591,22 @@ func TestAboutDotnet(t *testing.T) {
// This one doesn't have a current stack. Assert that we caught it.
assert.Contains(t, stderr, "No current stack")
}
// Tests dynamic provider in Dotnet.
func TestDynamicDotnet(t *testing.T) {
var randomVal string
integration.ProgramTest(t, &integration.ProgramTestOptions{
Dir: filepath.Join("dynamic", "dotnet"),
Dependencies: []string{"Pulumi"},
ExtraRuntimeValidation: func(t *testing.T, stack integration.RuntimeValidationStackInfo) {
randomVal = stack.Outputs["random_val"].(string)
},
EditDirs: []integration.EditDir{{
Dir: "step1",
Additive: true,
ExtraRuntimeValidation: func(t *testing.T, stack integration.RuntimeValidationStackInfo) {
assert.Equal(t, randomVal, stack.Outputs["random_val"].(string))
},
}},
})
}