smiklosovic commented on code in PR #3240:
URL: https://github.com/apache/cassandra/pull/3240#discussion_r1558523694
##########
test/unit/org/apache/cassandra/triggers/TriggersTest.java:
##########
@@ -80,6 +97,57 @@ public void setup() throws Exception
}
}
+ @After
+ public void after()
+ {
+ DatabaseDescriptor.setTriggersPolicy(originalTriggersPolicy);
+ }
+
+ @Test
+ public void testTriggersPolicy()
+ {
+ QueryProcessor.process(String.format("INSERT INTO %s.%s (k, v1) VALUES
(0, 0)", ksName, cfName), ConsistencyLevel.ONE);
+ assertUpdateIsAugmented(0, "v1", 0);
+ QueryProcessor.process(String.format("DELETE FROM %s.%s WHERE k = 0",
ksName, cfName), ConsistencyLevel.ONE);
+
+ DatabaseDescriptor.setTriggersPolicy(TriggersPolicy.disabled);
+ QueryProcessor.process(String.format("INSERT INTO %s.%s (k, v1) VALUES
(0, 0)", ksName, cfName), ConsistencyLevel.ONE);
+
+ UntypedResultSet rs = QueryProcessor.process(String.format("SELECT *
FROM %s.%s WHERE k=%s", ksName, cfName, 0), ConsistencyLevel.ONE);
+ assertRowValue(rs.one(), 0, "v1", 0); // from original update
+ assertEquals(-1, rs.one().getInt("v2", -1)); // from trigger
+ QueryProcessor.process(String.format("DELETE FROM %s.%s WHERE k = 0",
ksName, cfName), ConsistencyLevel.ONE);
+
+ DatabaseDescriptor.setTriggersPolicy(TriggersPolicy.forbidden);
+ try
Review Comment:
this whole try-catch might be replaced with more idiomatic
`Assertions.assertThatThrownBy`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]