pulumi/sdk/dotnet/Pulumi.Tests/Serialization/ListOutputCompletionSourceTests.cs
Fraser Waters d39a14432f
Don't throw on type mismatches in the dotnet sdk (#8286)
* Don't throw on type mismatches in the dotnet sdk

Fixes #7329

The converter will no longer throw if resource providers return data
that does not match the expected type declared in the dotnet sdk.
Instead a warning will be logged for the resource and the value will be
set to `default(T)`.
2021-10-29 17:35:17 +01:00

62 lines
2.1 KiB
C#

// Copyright 2016-2019, Pulumi Corporation
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Threading.Tasks;
using Pulumi.Serialization;
using Xunit;
namespace Pulumi.Tests.Serialization
{
public class ListConverterTests : ConverterTests
{
[Fact]
public async Task EmptyList()
{
var data = Converter.ConvertValue<ImmutableArray<bool>>(NoWarn, "", await SerializeToValueAsync(new List<bool>()));
Assert.Equal(ImmutableArray<bool>.Empty, data.Value);
Assert.True(data.IsKnown);
}
[Fact]
public async Task ListWithElement()
{
var data = Converter.ConvertValue<ImmutableArray<bool>>(NoWarn, "", await SerializeToValueAsync(new List<bool> { true }));
AssertEx.SequenceEqual(ImmutableArray<bool>.Empty.Add(true), data.Value);
Assert.True(data.IsKnown);
}
[Fact]
public async Task SecretListWithElement()
{
var data = Converter.ConvertValue<ImmutableArray<bool>>(NoWarn, "", await SerializeToValueAsync(Output.CreateSecret(new List<object> { true })));
AssertEx.SequenceEqual(ImmutableArray<bool>.Empty.Add(true), data.Value);
Assert.True(data.IsKnown);
Assert.True(data.IsSecret);
}
[Fact]
public async Task ListWithSecretElement()
{
var data = Converter.ConvertValue<ImmutableArray<bool>>(NoWarn, "", await SerializeToValueAsync(new List<object> { Output.CreateSecret(true) }));
AssertEx.SequenceEqual(ImmutableArray<bool>.Empty.Add(true), data.Value);
Assert.True(data.IsKnown);
Assert.True(data.IsSecret);
}
[Fact]
public async Task ListWithUnknownElement()
{
var data = Converter.ConvertValue<ImmutableArray<bool>>(NoWarn, "", await SerializeToValueAsync(new List<object> { Output<bool>.CreateUnknown(true) }));
AssertEx.SequenceEqual(ImmutableArray<bool>.Empty.Add(false), data.Value);
Assert.False(data.IsKnown);
Assert.False(data.IsSecret);
}
}
}