@@ -29,3 +29,55 @@ func TestAnalyzerWarnOnly(t *testing.T) {
2929 analyzer := newAnalyzer (cfg )
3030 analysistest .Run (t , testdata , analyzer , "a" )
3131}
32+
33+ func TestAnalyzerWithCustomMarkers (t * testing.T ) {
34+ testdata := analysistest .TestData ()
35+ cfg := & MarkerScopeConfig {
36+ Policy : MarkerScopePolicyWarn ,
37+ MarkerRules : map [string ]MarkerScopeRule {
38+ // Custom field-only marker
39+ "custom:field-only" : {
40+ Scope : FieldScope ,
41+ },
42+ // Custom type-only marker
43+ "custom:type-only" : {
44+ Scope : TypeScope ,
45+ },
46+ // Custom marker with string type constraint
47+ "custom:string-only" : {
48+ Scope : FieldScope ,
49+ TypeConstraint : & TypeConstraint {
50+ AllowedSchemaTypes : []SchemaType {SchemaTypeString },
51+ },
52+ },
53+ // Custom marker with integer type constraint
54+ "custom:integer-only" : {
55+ Scope : FieldScope ,
56+ TypeConstraint : & TypeConstraint {
57+ AllowedSchemaTypes : []SchemaType {SchemaTypeInteger },
58+ },
59+ },
60+ // Custom marker with array of strings constraint
61+ "custom:string-array" : {
62+ Scope : FieldScope ,
63+ TypeConstraint : & TypeConstraint {
64+ AllowedSchemaTypes : []SchemaType {SchemaTypeArray },
65+ ElementConstraint : & TypeConstraint {
66+ AllowedSchemaTypes : []SchemaType {SchemaTypeString },
67+ },
68+ },
69+ },
70+ },
71+ }
72+ analyzer := newAnalyzer (cfg )
73+ analysistest .Run (t , testdata , analyzer , "b" )
74+ }
75+
76+ func TestAnalyzerWithSuggestFix (t * testing.T ) {
77+ testdata := analysistest .TestData ()
78+ cfg := & MarkerScopeConfig {
79+ Policy : MarkerScopePolicySuggestFix ,
80+ }
81+ analyzer := newAnalyzer (cfg )
82+ analysistest .RunWithSuggestedFixes (t , testdata , analyzer , "c" )
83+ }
0 commit comments