|
|
@@ -394,3 +394,45 @@ func TestTranslate(t *testing.T) {
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+func TestExtendedRuleKeywordsAreDowncase(t *testing.T) {
|
|
|
+ tests := []struct {
|
|
|
+ name string
|
|
|
+ cfgName string
|
|
|
+ expectedKeywords string
|
|
|
+ }{
|
|
|
+ {
|
|
|
+ name: "Extend base rule that includes AWS keyword with new attribute",
|
|
|
+ cfgName: "extend_base_rule_including_keysword_with_attribute",
|
|
|
+ expectedKeywords: "aws",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: "Extend base with a new rule with CMS keyword",
|
|
|
+ cfgName: "extend_with_new_rule",
|
|
|
+ expectedKeywords: "cms",
|
|
|
+ },
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, tt := range tests {
|
|
|
+ t.Run(tt.name, func(t *testing.T) {
|
|
|
+ t.Cleanup(func() {
|
|
|
+ viper.Reset()
|
|
|
+ })
|
|
|
+
|
|
|
+ viper.AddConfigPath(configPath)
|
|
|
+ viper.SetConfigName(tt.cfgName)
|
|
|
+ viper.SetConfigType("toml")
|
|
|
+ err := viper.ReadInConfig()
|
|
|
+ require.NoError(t, err)
|
|
|
+
|
|
|
+ var vc ViperConfig
|
|
|
+ err = viper.Unmarshal(&vc)
|
|
|
+ require.NoError(t, err)
|
|
|
+ cfg, err := vc.Translate()
|
|
|
+ require.NoError(t, err)
|
|
|
+
|
|
|
+ _, exists := cfg.Keywords[tt.expectedKeywords]
|
|
|
+ require.Truef(t, exists, "The expected keyword %s did not exist as a key of cfg.Keywords", tt.expectedKeywords)
|
|
|
+ })
|
|
|
+ }
|
|
|
+}
|