@@ -10,82 +10,6 @@ import (
1010 "github.com/stretchr/testify/assert"
1111)
1212
13- << << << < HEAD
14- == == == =
15- func TestUnmarshal (t * testing.T ) {
16- t .Run ("partial path override preserves defaults" , func (t * testing.T ) {
17- cfg := & Config {
18- Beatconfig : map [string ]any {
19- "path" : map [string ]any {
20- "home" : "/default/home" ,
21- "data" : "/default/data" ,
22- },
23- },
24- }
25-
26- userConf := confmap .NewFromStringMap (map [string ]any {
27- "path.home" : "/custom/home" ,
28- "filebeat" : map [string ]any {"inputs" : []any {}},
29- })
30-
31- require .NoError (t , cfg .Unmarshal (userConf ))
32-
33- pathMap , ok := cfg .Beatconfig ["path" ].(map [string ]any )
34- require .True (t , ok , "path should be a map" )
35- assert .Equal (t , "/custom/home" , pathMap ["home" ], "user override should win" )
36- assert .Equal (t , "/default/data" , pathMap ["data" ], "unspecified default should be preserved" )
37- assert .Contains (t , cfg .Beatconfig , "filebeat" )
38- })
39-
40- t .Run ("no defaults does not error" , func (t * testing.T ) {
41- cfg := & Config {}
42-
43- userConf := confmap .NewFromStringMap (map [string ]any {
44- "filebeat" : map [string ]any {"inputs" : []any {}},
45- })
46-
47- require .NoError (t , cfg .Unmarshal (userConf ))
48- assert .Contains (t , cfg .Beatconfig , "filebeat" )
49- })
50-
51- t .Run ("full path override replaces both" , func (t * testing.T ) {
52- cfg := & Config {
53- Beatconfig : map [string ]any {
54- "path" : map [string ]any {
55- "home" : "/default/home" ,
56- "data" : "/default/data" ,
57- },
58- },
59- }
60-
61- userConf := confmap .NewFromStringMap (map [string ]any {
62- "path" : map [string ]any {
63- "home" : "/custom/home" ,
64- "data" : "/custom/data" ,
65- },
66- "filebeat" : map [string ]any {"inputs" : []any {}},
67- })
68-
69- require .NoError (t , cfg .Unmarshal (userConf ))
70-
71- pathMap , ok := cfg .Beatconfig ["path" ].(map [string ]any )
72- require .True (t , ok )
73- assert .Equal (t , "/custom/home" , pathMap ["home" ])
74- assert .Equal (t , "/custom/data" , pathMap ["data" ])
75- })
76- }
77-
78- func TestUnmarshalIncludeMetadata (t * testing.T ) {
79- cfg := & Config {}
80- userConf := confmap .NewFromStringMap (map [string ]any {
81- "include_metadata" : true ,
82- "filebeat" : map [string ]any {"inputs" : []any {}},
83- })
84- require .NoError (t , cfg .Unmarshal (userConf ))
85- assert .Equal (t , true , cfg .Beatconfig ["include_metadata" ])
86- }
87-
88- >> >> >> > 2e949 e6c4 (otel : option to preserve at metadata field in log record body (#50191 ))
8913func TestValidate (t * testing.T ) {
9014 tests := map [string ]struct {
9115 c * Config
0 commit comments