|
739 | 739 | end |
740 | 740 | end |
741 | 741 |
|
| 742 | + context "when previous runs are to be respected upon successful query execution (by time string)" do |
| 743 | + |
| 744 | + let(:settings) do |
| 745 | + { "statement" => "SELECT custom_time FROM test_table WHERE custom_time > :sql_last_value", |
| 746 | + "use_column_value" => true, |
| 747 | + "tracking_column" => "custom_time", |
| 748 | + "tracking_column_type" => "timestamp", |
| 749 | + "last_run_metadata_path" => Stud::Temporary.pathname } |
| 750 | + end |
| 751 | + |
| 752 | + let(:last_run_time) { '2010-03-19T14:48:40.483Z' } |
| 753 | + |
| 754 | + before do |
| 755 | + File.write(settings["last_run_metadata_path"], YAML.dump(last_run_time)) |
| 756 | + test_table = db[:test_table] |
| 757 | + test_table.insert(:num => 0, :custom_time => Time.now.utc) |
| 758 | + plugin.register |
| 759 | + end |
| 760 | + |
| 761 | + after do |
| 762 | + plugin.stop |
| 763 | + end |
| 764 | + |
| 765 | + it "should respect last run metadata" do |
| 766 | + plugin.run(queue) |
| 767 | + expect(plugin.instance_variable_get("@value_tracker").value).to be > DateTime.parse(last_run_time).to_time |
| 768 | + end |
| 769 | + end |
| 770 | + |
| 771 | + context "when previous runs are to be respected upon successful query execution (by date/time string)" do |
| 772 | + |
| 773 | + let(:settings) do |
| 774 | + { "statement" => "SELECT custom_time FROM test_table WHERE custom_time > :sql_last_value", |
| 775 | + "use_column_value" => true, |
| 776 | + "tracking_column" => "custom_time", |
| 777 | + "tracking_column_type" => "timestamp", |
| 778 | + "jdbc_default_timezone" => "UTC", #this triggers the last_run_time to be treated as date/time |
| 779 | + "last_run_metadata_path" => Stud::Temporary.pathname } |
| 780 | + end |
| 781 | + |
| 782 | + let(:last_run_time) { '2010-03-19T14:48:40.483Z' } |
| 783 | + |
| 784 | + before do |
| 785 | + File.write(settings["last_run_metadata_path"], YAML.dump(last_run_time)) |
| 786 | + test_table = db[:test_table] |
| 787 | + test_table.insert(:num => 0, :custom_time => Time.now.utc) |
| 788 | + plugin.register |
| 789 | + end |
| 790 | + |
| 791 | + after do |
| 792 | + plugin.stop |
| 793 | + end |
| 794 | + |
| 795 | + it "should respect last run metadata" do |
| 796 | + plugin.run(queue) |
| 797 | + expect(plugin.instance_variable_get("@value_tracker").value).to be > DateTime.parse(last_run_time) |
| 798 | + end |
| 799 | + end |
| 800 | + |
742 | 801 | context "when previous runs are to be respected upon successful query execution (by column)" do |
743 | 802 |
|
744 | 803 | let(:settings) do |
|
0 commit comments