File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed
monitoring/v3/src/test/java/com/example Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -96,8 +96,22 @@ public void testReplaceChannels() throws IOException {
9696 @ Test
9797 public void testDisableEnablePolicies () throws IOException {
9898 AlertSample .main (new String [] {"enable" , "-d" , "display_name='test-policy'" });
99- assertTrue (bout .toString ().contains ("enabled" ));
100- AlertSample .main (new String [] {"disable" , "-d" , "display_name='test-policy'" });
101- assertTrue (bout .toString ().contains ("disabled" ));
99+
100+ // check the current state of policy to make sure
101+ // not to enable the policy that is already enabled.
102+ boolean isEnabled = bout .toString ().contains ("already" );
103+ if (isEnabled ) {
104+ AlertSample .main (new String [] {"disable" , "-d" , "display_name='test-policy'" });
105+ assertTrue (bout .toString ().contains ("disabled" ));
106+
107+ AlertSample .main (new String [] {"enable" , "-d" , "display_name='test-policy'" });
108+ assertTrue (bout .toString ().contains ("enabled" ));
109+ } else {
110+ AlertSample .main (new String [] {"enable" , "-d" , "display_name='test-policy'" });
111+ assertTrue (bout .toString ().contains ("enabled" ));
112+
113+ AlertSample .main (new String [] {"disable" , "-d" , "display_name='test-policy'" });
114+ assertTrue (bout .toString ().contains ("disabled" ));
115+ }
102116 }
103117}
You can’t perform that action at this time.
0 commit comments