Sha256: a1f9066cd46ac7802b59fa2e3253343fd4bc15a46d586fd2050ce5f6cbec901b

Contents?: true

Size: 1.43 KB

Versions: 2

Compression:

Stored size: 1.43 KB

Contents

require 'test_helper'

module Sidekiq
  module Benchmark
    module Test
      TOKEN = SecureRandom.base64(32).freeze

      describe "Web extention" do
        include Rack::Test::Methods

        def app
          @app ||= Sidekiq::Web
        end

        before do
          env 'rack.session', { csrf: TOKEN }
          env 'HTTP_X_CSRF_TOKEN', TOKEN
          Test.flush_db
        end

        it "display index without stats" do
          get '/benchmarks'
          _(last_response.status).must_equal 200
        end

        it "display index with stats" do
          WorkerMock.new

          get '/benchmarks'
          _(last_response.status).must_equal 200
        end

        it "remove all benchmarks data" do
          WorkerMock.new

          Sidekiq.redis { |conn| _(conn.keys("benchmark:*")).wont_be_empty }

          post '/benchmarks/remove_all'
          _(last_response.status).must_equal 302

          Sidekiq.redis { |conn| _(conn.keys("benchmark:*")).must_be_empty }
        end

        it "remove benchmark data" do
          WorkerMock.new

          Sidekiq.redis { |conn| _(conn.keys("benchmark:sidekiq_benchmark_test_workermock:*")).wont_be_empty }

          post '/benchmarks/remove', type: :sidekiq_benchmark_test_workermock
          _(last_response.status).must_equal 302

          Sidekiq.redis { |conn| _(conn.keys("benchmark:sidekiq_benchmark_test_workermock:*")).must_be_empty }
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sidekiq-benchmark-0.7.3 test/lib/web_test.rb
sidekiq-benchmark-0.7.2 test/lib/web_test.rb