|
7 | 7 | using KubeOps.Operator.Commands.Generators;
|
8 | 8 | using KubeOps.Operator.Entities.Extensions;
|
9 | 9 | using KubeOps.Operator.Errors;
|
10 |
| -using KubeOps.Operator.Services; |
11 | 10 | using KubeOps.Test.TestEntities;
|
12 | 11 | using Xunit;
|
13 | 12 |
|
@@ -74,30 +73,43 @@ public void Should_Set_The_Correct_Type_And_Format_For_Types(string fieldName, s
|
74 | 73 | nullableField.Nullable.Should().BeTrue();
|
75 | 74 | }
|
76 | 75 |
|
77 |
| - [Fact] |
78 |
| - public void Should_Set_The_Correct_Array_Type() |
79 |
| - { |
| 76 | + [Theory] |
| 77 | + [InlineData(nameof(TestSpecEntitySpec.StringArray), "string", null)] |
| 78 | + [InlineData(nameof(TestSpecEntitySpec.NullableStringArray), "string", true)] |
| 79 | + [InlineData(nameof(TestSpecEntitySpec.EnumerableInteger), "integer", null)] |
| 80 | + [InlineData(nameof(TestSpecEntitySpec.EnumerableNullableInteger), "integer", null)] |
| 81 | + [InlineData(nameof(TestSpecEntitySpec.IntegerList), "integer", null)] |
| 82 | + [InlineData(nameof(TestSpecEntitySpec.IntegerHashSet), "integer", null)] |
| 83 | + [InlineData(nameof(TestSpecEntitySpec.IntegerISet), "integer", null)] |
| 84 | + [InlineData(nameof(TestSpecEntitySpec.IntegerIReadOnlySet), "integer", null)] |
| 85 | + public void Should_Set_The_Correct_Array_Type(string property, string expectedType, bool? expectedNullable) |
| 86 | + { |
| 87 | + var propertyName = char.ToLowerInvariant(property[0]) + property[1..]; |
80 | 88 | var crd = _testSpecEntity.CreateCrd();
|
81 | 89 | var specProperties = crd.Spec.Versions.First().Schema.OpenAPIV3Schema.Properties["spec"];
|
82 | 90 |
|
83 |
| - var normalField = specProperties.Properties["stringArray"]; |
| 91 | + var normalField = specProperties.Properties[propertyName]; |
84 | 92 | normalField.Type.Should().Be("array");
|
85 |
| - (normalField.Items as V1JSONSchemaProps)?.Type?.Should().Be("string"); |
86 |
| - normalField.Nullable.Should().BeNull(); |
87 |
| - |
88 |
| - var nullableField = specProperties.Properties["nullableStringArray"]; |
89 |
| - nullableField.Type.Should().Be("array"); |
90 |
| - (nullableField.Items as V1JSONSchemaProps)?.Type?.Should().Be("string"); |
91 |
| - nullableField.Nullable.Should().BeTrue(); |
| 93 | + (normalField.Items as V1JSONSchemaProps)?.Type?.Should().Be(expectedType); |
| 94 | + normalField.Nullable.Should().Be(expectedNullable); |
92 | 95 | }
|
93 | 96 |
|
94 |
| - [Fact] |
95 |
| - public void Should_Set_The_Correct_Complex_Array_Type() |
96 |
| - { |
| 97 | + [Theory] |
| 98 | + [InlineData(nameof(TestSpecEntitySpec.ComplexItemsEnumerable))] |
| 99 | + [InlineData(nameof(TestSpecEntitySpec.ComplexItemsList))] |
| 100 | + [InlineData(nameof(TestSpecEntitySpec.ComplexItemsIList))] |
| 101 | + [InlineData(nameof(TestSpecEntitySpec.ComplexItemsReadOnlyList))] |
| 102 | + [InlineData(nameof(TestSpecEntitySpec.ComplexItemsCollection))] |
| 103 | + [InlineData(nameof(TestSpecEntitySpec.ComplexItemsICollection))] |
| 104 | + [InlineData(nameof(TestSpecEntitySpec.ComplexItemsReadOnlyCollection))] |
| 105 | + [InlineData(nameof(TestSpecEntitySpec.ComplexItemsDerivedList))] |
| 106 | + public void Should_Set_The_Correct_Complex_Array_Type(string property) |
| 107 | + { |
| 108 | + var propertyName = char.ToLowerInvariant(property[0]) + property[1..]; |
97 | 109 | var crd = _testSpecEntity.CreateCrd();
|
98 | 110 | var specProperties = crd.Spec.Versions.First().Schema.OpenAPIV3Schema.Properties["spec"];
|
99 | 111 |
|
100 |
| - var complexItemsArray = specProperties.Properties["complexItems"]; |
| 112 | + var complexItemsArray = specProperties.Properties[propertyName]; |
101 | 113 | complexItemsArray.Type.Should().Be("array");
|
102 | 114 | (complexItemsArray.Items as V1JSONSchemaProps)?.Type?.Should().Be("object");
|
103 | 115 | complexItemsArray.Nullable.Should().BeNull();
|
|
0 commit comments