regulators: Add test cases for object 'run_rule'.

*Valid: test run_rule.
*Invalid: test run_rule wrong type.
*Invalid: test run_rule wrong format.

Signed-off-by: Bob King <Bob_King@wistron.com>
Change-Id: I38d8aba32f09ac36c4128ca75558a835fdb5622a
diff --git a/phosphor-regulators/test/validate-regulators-config_tests.cpp b/phosphor-regulators/test/validate-regulators-config_tests.cpp
index 43535b6..41b991f 100644
--- a/phosphor-regulators/test/validate-regulators-config_tests.cpp
+++ b/phosphor-regulators/test/validate-regulators-config_tests.cpp
@@ -1213,3 +1213,28 @@
                             "u'foo' is not one of [u'linear']");
     }
 }
+TEST(ValidateRegulatorsConfigTest, RunRule)
+{
+    json runRuleFile = validConfigFile;
+    runRuleFile["rules"][0]["actions"][1]["run_rule"] = "set_voltage_rule1";
+    // Valid: test run_rule.
+    {
+        json configFile = runRuleFile;
+        EXPECT_JSON_VALID(configFile);
+    }
+    // Invalid: test run_rule wrong type.
+    {
+        json configFile = runRuleFile;
+        configFile["rules"][0]["actions"][1]["run_rule"] = true;
+        EXPECT_JSON_INVALID(configFile, "Validation failed.",
+                            "True is not of type u'string'");
+    }
+    // Invalid: test run_rule wrong format.
+    {
+        json configFile = runRuleFile;
+        configFile["rules"][0]["actions"][1]["run_rule"] = "set_voltage_rule%";
+        EXPECT_JSON_INVALID(
+            configFile, "Validation failed.",
+            "u'set_voltage_rule%' does not match u'^[A-Za-z0-9_]+$'");
+    }
+}