gflow-aggregator-test.vala 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. using GFlow;
  2. public class GFlowTest.AggregatorTest {
  3. public static void add_tests() {
  4. Test.add_func("/gflow/aggregator/array-attributes",
  5. () => {
  6. var new_flow_id = "test";
  7. var aggregator = Aggregator.get_instance();
  8. var pipeline = aggregator.new_aggregation_pipeline(new_flow_id);
  9. pipeline.set_array_attribute_at_index("test", "value1", 0);
  10. pipeline.set_array_attribute_at_index("test", "value2", 1);
  11. pipeline.set_array_attribute_at_index("test", "value3", 2);
  12. pipeline.commit(new TestPredicate(), pipeline => {
  13. var list = pipeline.get_array_attribute("test");
  14. assert(list.length == 3);
  15. return true;
  16. });
  17. });
  18. }
  19. public class TestPredicate : AggregationPredicate, Object {
  20. public bool should_commit (GFlow.AggregationPipeline aggregation_pipeline) {
  21. return aggregation_pipeline.get_array_attribute("test").length == 3;
  22. }
  23. }
  24. }