Skip to content

Commit 63ba090

Browse files
committed
changelog added
Signed-off-by: Mujib Ahasan <ahasanmujib8@gmail.com>
1 parent d2383d4 commit 63ba090

2 files changed

Lines changed: 25 additions & 82 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. receiver/otlp)
7+
component: cmd/mdatagen
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Handle array validators in generated config structs
11+
12+
# One or more tracking issues or pull requests related to the change
13+
issues: [14808]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext: Supported validators include `minItems`, `maxItems`, `uniqueItems` and `contains`.
19+
20+
# Optional: The change log or logs in which this entry should be included.
21+
# e.g. '[user]' or '[user, api]'
22+
# Include 'user' if the change is relevant to end users.
23+
# Include 'api' if there is a change to a library API.
24+
# Default: '[user]'
25+
change_logs: [api]

cmd/mdatagen/internal/cfggen/generation_test.go

Lines changed: 0 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -3345,85 +3345,3 @@ func TestValidationRules_HasValueRule_ArrayValidators(t *testing.T) {
33453345
})
33463346
}
33473347
}
3348-
3349-
func TestExtractImports_ArrayValidators(t *testing.T) {
3350-
tests := []struct {
3351-
name string
3352-
metadata *ConfigMetadata
3353-
expectedImport string
3354-
}{
3355-
{
3356-
name: "minItems triggers errors import",
3357-
metadata: &ConfigMetadata{
3358-
Type: ObjectType,
3359-
Properties: map[string]*ConfigMetadata{
3360-
"tags": {Type: SliceType, Values: &ConfigMetadata{Type: StringType}, MinItems: Ptr(1)},
3361-
},
3362-
},
3363-
expectedImport: "errors",
3364-
},
3365-
{
3366-
name: "maxItems triggers errors import",
3367-
metadata: &ConfigMetadata{
3368-
Type: ObjectType,
3369-
Properties: map[string]*ConfigMetadata{
3370-
"tags": {Type: SliceType, Values: &ConfigMetadata{Type: StringType}, MaxItems: Ptr(10)},
3371-
},
3372-
},
3373-
expectedImport: "errors",
3374-
},
3375-
{
3376-
name: "uniqueItems triggers errors import",
3377-
metadata: &ConfigMetadata{
3378-
Type: ObjectType,
3379-
Properties: map[string]*ConfigMetadata{
3380-
"tags": {Type: SliceType, Values: &ConfigMetadata{Type: StringType}, UniqueItems: true},
3381-
},
3382-
},
3383-
expectedImport: "errors",
3384-
},
3385-
{
3386-
name: "contains with enum triggers slices import",
3387-
metadata: &ConfigMetadata{
3388-
Type: ObjectType,
3389-
Properties: map[string]*ConfigMetadata{
3390-
"tags": {
3391-
Type: SliceType,
3392-
Values: &ConfigMetadata{Type: StringType},
3393-
Contains: &ConfigMetadata{Type: StringType, Enum: []any{"a"}},
3394-
},
3395-
},
3396-
},
3397-
expectedImport: "slices",
3398-
},
3399-
}
3400-
3401-
for _, tt := range tests {
3402-
t.Run(tt.name, func(t *testing.T) {
3403-
result, err := ExtractImportsFromConfig(tt.metadata, "", "")
3404-
require.NoError(t, err)
3405-
require.Contains(t, result, tt.expectedImport)
3406-
})
3407-
}
3408-
}
3409-
3410-
func TestSchemaTypeToGoType(t *testing.T) {
3411-
tests := []struct {
3412-
schemaType SchemaType
3413-
expected string
3414-
}{
3415-
{StringType, "string"},
3416-
{IntType, "int"},
3417-
{Float64Type, "float64"},
3418-
{BoolType, "bool"},
3419-
{ObjectType, "any"},
3420-
{SliceType, "any"},
3421-
{"", "any"},
3422-
}
3423-
3424-
for _, tt := range tests {
3425-
t.Run(string(tt.schemaType), func(t *testing.T) {
3426-
require.Equal(t, tt.expected, schemaTypeToGoType(tt.schemaType))
3427-
})
3428-
}
3429-
}

0 commit comments

Comments
 (0)