From 5517f022cdb6233551c9281422c033d18293ec03 Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Tue, 17 Feb 2015 01:35:41 -0500 Subject: [PATCH] 4759: Add functional tests for timestamp precision. --- .../functional/arvados/v1/filters_test.rb | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/services/api/test/functional/arvados/v1/filters_test.rb b/services/api/test/functional/arvados/v1/filters_test.rb index 604f421481..2349993617 100644 --- a/services/api/test/functional/arvados/v1/filters_test.rb +++ b/services/api/test/functional/arvados/v1/filters_test.rb @@ -54,4 +54,42 @@ class Arvados::V1::FiltersTest < ActionController::TestCase assert_response 422 assert_match /not supported/, json_response['errors'].join(' ') end + + test 'api responses provide timestamps with nanoseconds' do + @controller = Arvados::V1::CollectionsController.new + authorize_with :active + get :index + assert_response :success + assert_not_empty json_response['items'] + json_response['items'].each do |item| + %w(created_at modified_at).each do |attr| + # Pass fixtures with null timestamps. + next if item[attr].nil? + assert_match /^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d.\d{9}Z$/, item[attr] + end + end + end + + %w(< > <= >= =).each do |operator| + test "timestamp #{operator} filters work with nanosecond precision" do + expect_match = !!operator.index('=') + mine = act_as_user users(:active) do + Collection.create!(manifest_text: '') + end + timestamp = mine.modified_at.strftime('%Y-%m-%dT%H:%M:%S.%NZ') + @controller = Arvados::V1::CollectionsController.new + authorize_with :active + get :index, { + filters: [['modified_at', operator, timestamp], + ['uuid', '=', mine.uuid]], + } + assert_response :success + uuids = json_response['items'].map { |item| item['uuid'] } + if expect_match + assert_includes uuids, mine.uuid + else + assert_not_includes uuids, mine.uuid + end + end + end end -- 2.30.2