Sha256: b3560414b2c60d73f34501d38d24273b94756356e05fa9dadebea6e26f0439bb

Contents?: true

Size: 1.97 KB

Versions: 2

Compression:

Stored size: 1.97 KB

Contents

require "integration_spec_helper"

RSpec.describe "Actions for Queues", :sqs do

  let(:sqs) { Aws::SQS::Client.new }
  before do
    sqs.config.endpoint = $fake_sqs.uri
  end

  specify "CreateQueue" do
    response = sqs.create_queue(queue_name: "test-create-queue")
    expect(response.queue_url).to eq "http://0.0.0.0:4568/test-create-queue"
    response2 = sqs.get_queue_attributes(queue_url: response.queue_url)
    expect(response2.attributes.fetch("QueueArn")).to match %r"arn:aws:sqs:us-east-1:.+:test-create-queue"
  end

  specify "GetQueueUrl" do
    sqs.create_queue(queue_name: "test-get-queue-url")
    response = sqs.get_queue_url(queue_name: "test-get-queue-url")
    expect(response.queue_url).to eq "http://0.0.0.0:4568/test-get-queue-url"
  end

  specify "ListQueues" do
    sqs.create_queue(queue_name: "test-list-1")
    sqs.create_queue(queue_name: "test-list-2")
    expect(sqs.list_queues.queue_urls).to eq [
      "http://0.0.0.0:4568/test-list-1",
      "http://0.0.0.0:4568/test-list-2"
    ]
  end

  specify "ListQueues with prefix" do
    sqs.create_queue(queue_name: "test-list-1")
    sqs.create_queue(queue_name: "test-list-2")
    sqs.create_queue(queue_name: "other-list-3")
    expect(sqs.list_queues(queue_name_prefix: "test").queue_urls).to eq [
      "http://0.0.0.0:4568/test-list-1",
      "http://0.0.0.0:4568/test-list-2",
    ]
  end

  specify "DeleteQueue" do
    url = sqs.create_queue(queue_name: "test-delete").queue_url
    expect(sqs.list_queues.queue_urls.size).to eq 1
    sqs.delete_queue(queue_url: url)
    expect(sqs.list_queues.queue_urls.size).to eq 0
  end

  specify "SetQueueAttributes / GetQueueAttributes" do
    queue_url = sqs.create_queue(queue_name: "my-queue").queue_url


    sqs.set_queue_attributes(
      queue_url: queue_url,
      attributes: {
        "DelaySeconds" => "900"
      }
    )

    response = sqs.get_queue_attributes(
      queue_url: queue_url,
    )
    expect(response.attributes.fetch("DelaySeconds")).to eq "900"
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fake_sqs-0.3.1 spec/acceptance/queue_actions_spec.rb
fake_sqs-0.3.0 spec/acceptance/queue_actions_spec.rb