pulumi/pkg/codegen/dotnet/gen_program_test.go

65 lines
1.8 KiB
Go

// Copyright 2020-2024, Pulumi Corporation.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package dotnet
import (
"testing"
"github.com/pulumi/pulumi/pkg/v3/codegen"
"github.com/pulumi/pulumi/pkg/v3/codegen/testing/test"
)
func TestGenerateProgramVersionSelection(t *testing.T) {
t.Parallel()
expectedVersion := map[string]test.PkgVersionInfo{
"aws-resource-options-4.26": {
Pkg: "<PackageReference Include=\"Pulumi.Aws\"",
OpAndVersion: "Version=\"4.26.0\"",
},
"aws-resource-options-5.16.2": {
Pkg: "<PackageReference Include=\"Pulumi.Aws\"",
OpAndVersion: "Version=\"5.16.2\"",
},
}
test.TestProgramCodegen(t,
test.ProgramCodegenOptions{
Language: "dotnet",
Extension: "cs",
OutputFile: "Program.cs",
Check: func(t *testing.T, path string, dependencies codegen.StringSet) {
Check(t, path, dependencies, "")
},
GenProgram: GenerateProgram,
TestCases: []test.ProgramTest{
{
Directory: "aws-resource-options-4.26",
Description: "Resource Options",
},
{
Directory: "aws-resource-options-5.16.2",
Description: "Resource Options",
},
},
IsGenProject: true,
GenProject: GenerateProject,
ExpectedVersion: expectedVersion,
DependencyFile: "test.csproj",
},
)
}