Skip to content
  • Ryuta Kamizono's avatar
    19d01d19
    Fix `CURRENT_TIMESTAMP` test failure by setting time_zone correctly · 19d01d19
    Ryuta Kamizono authored
    The following tests using `CURRENT_TIMESTAMP` currently fail when run in
    a timezone other than UTC.
    
    ```
    % bin/test -a trilogy test/cases/dirty_test.rb -n test_partial_insert_off_with_unchanged_default_function_attribute
    Using trilogy
    Run options: -n test_partial_insert_off_with_unchanged_default_function_attribute --seed 35804
    
    # Running:
    
    F
    
    Failure:
    DirtyTest#test_partial_insert_off_with_unchanged_default_function_attribute [test/cases/dirty_test.rb:954]:
    Expected 2024-10-11 15:00:23.376205 +0900..2024-10-11 15:00:25.376717 +0900 to include 2024-10-11 15:00:24 UTC.
    
    bin/test test/cases/dirty_test.rb:943
    
    Finished in 0.024596s, 40.6570 runs/s, 162.6281 assertions/s.
    1 runs, 4 assertions, 1 failures, 0 errors, 0 skips
    ```
    
    https://github.com/rails/rails/blob/57fe7e781ee37a50e54b17df24738ce6c26b22db/activerecord/test/cases/dirty_test.rb#L943-L956
    https://github.com/rails/rails/blob/57fe7e781ee37a50e54b17df24738ce6c26b22db/activerecord/test/schema/schema.rb#L59-L64
    
    And add an extra test to test `high_precision_current_timestamp` which
    fail without setting time_zone correctly.
    
    ```
    % bin/test -a trilogy test/cases/date_time_test.rb -n test_high_precision_current_timestamp
    Using trilogy
    Run options: -n test_high_precision_current_timestamp --seed 33000
    
    # Running:
    
    F
    
    Failure:
    DateTimeTest#test_high_precision_current_timestamp [test/cases/date_time_test.rb:26]:
    Expected |2024-10-11 15:45:42 +0900 - 2024-10-11 15:45:42 UTC| (32399.999882) to be <= 0.001.
    
    bin/test test/cases/date_time_test.rb:20
    
    Finished in 0.016253s, 61.5271 runs/s, 61.5271 assertions/s.
    1 runs, 1 assertions, 1 failures, 0 errors, 0 skips
    ```
    19d01d19
    Fix `CURRENT_TIMESTAMP` test failure by setting time_zone correctly
    Ryuta Kamizono authored
    The following tests using `CURRENT_TIMESTAMP` currently fail when run in
    a timezone other than UTC.
    
    ```
    % bin/test -a trilogy test/cases/dirty_test.rb -n test_partial_insert_off_with_unchanged_default_function_attribute
    Using trilogy
    Run options: -n test_partial_insert_off_with_unchanged_default_function_attribute --seed 35804
    
    # Running:
    
    F
    
    Failure:
    DirtyTest#test_partial_insert_off_with_unchanged_default_function_attribute [test/cases/dirty_test.rb:954]:
    Expected 2024-10-11 15:00:23.376205 +0900..2024-10-11 15:00:25.376717 +0900 to include 2024-10-11 15:00:24 UTC.
    
    bin/test test/cases/dirty_test.rb:943
    
    Finished in 0.024596s, 40.6570 runs/s, 162.6281 assertions/s.
    1 runs, 4 assertions, 1 failures, 0 errors, 0 skips
    ```
    
    https://github.com/rails/rails/blob/57fe7e781ee37a50e54b17df24738ce6c26b22db/activerecord/test/cases/dirty_test.rb#L943-L956
    https://github.com/rails/rails/blob/57fe7e781ee37a50e54b17df24738ce6c26b22db/activerecord/test/schema/schema.rb#L59-L64
    
    And add an extra test to test `high_precision_current_timestamp` which
    fail without setting time_zone correctly.
    
    ```
    % bin/test -a trilogy test/cases/date_time_test.rb -n test_high_precision_current_timestamp
    Using trilogy
    Run options: -n test_high_precision_current_timestamp --seed 33000
    
    # Running:
    
    F
    
    Failure:
    DateTimeTest#test_high_precision_current_timestamp [test/cases/date_time_test.rb:26]:
    Expected |2024-10-11 15:45:42 +0900 - 2024-10-11 15:45:42 UTC| (32399.999882) to be <= 0.001.
    
    bin/test test/cases/date_time_test.rb:20
    
    Finished in 0.016253s, 61.5271 runs/s, 61.5271 assertions/s.
    1 runs, 1 assertions, 1 failures, 0 errors, 0 skips
    ```
Loading