Sha256: 122ea2990cb60ef70feab268044fe6324bf92e410de9b366176942677c02135f

Contents?: true

Size: 1.97 KB

Versions: 28

Compression:

Stored size: 1.97 KB

Contents

# encoding: UTF-8
#
# Copyright (c) 2010-2015 GoodData Corporation. All rights reserved.
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

require 'gooddata/helpers/data_helper'

describe GoodData::Helpers::DataSource do
  before :each do
    @s3_client = double('s3_client')
    @buckets = double('buckets')
    @bucket = double('bucket')
    @objects = double('objects')

    allow(@s3_client).to receive(:buckets) { @buckets }
    allow(@buckets).to receive(:[]) { @bucket }
    allow(@bucket).to receive(:objects) { @objects }
    allow(@objects).to receive(:[]) { StringIO.new('aaa') }

    @ds = GoodData::Helpers::DataSource.new({
      type: :s3,
      bucket: 'some_bucket',
      key: 'some_key'
    })
  end

  it 'should be able to handle AWS' do
    expect(@ds.realized?).to be_falsey
    params = { 'aws_client' => { 's3_client' => @s3_client } }
    expect(@ds.realize(params)).to eq '2bdc6c8a02b2bd1d7997cf17f0848ecfcbceba25ca184e2676f19c054db7139b'
    expect(@ds.realized?).to be_truthy
  end

  it 'should gracefully handle missing aws client' do
    expect do
      @ds.realize({
        'aws_client' => nil
      })
    end.to raise_exception "AWS client not present. Perhaps S3Middleware is missing in the brick definition?"
  end

  it 'should gracefully handle missing data source params - bucket' do
    ds = GoodData::Helpers::DataSource.new({
      type: :s3,
      key: 'some_key'
    })
    params = { 'aws_client' => { 's3_client' => @s3_client } }
    expect do
      ds.realize(params)
    end.to raise_exception 'Key "bucket" is missing in S3 datasource'
  end

  it 'should gracefully handle missing data source params - key' do
    ds = GoodData::Helpers::DataSource.new({
      type: :s3,
      bucket: 'some_bucket'
    })
    params = { 'aws_client' => { 's3_client' => @s3_client } }
    expect do
      ds.realize(params)
    end.to raise_exception 'Key "key" is missing in S3 datasource'
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
gooddata-0.6.49 spec/unit/helpers/data_helper_spec.rb
gooddata-0.6.48 spec/unit/helpers/data_helper_spec.rb
gooddata-0.6.47 spec/unit/helpers/data_helper_spec.rb
gooddata-0.6.46 spec/unit/helpers/data_helper_spec.rb
gooddata-0.6.45 spec/unit/helpers/data_helper_spec.rb
gooddata-0.6.44 spec/unit/helpers/data_helper_spec.rb
gooddata-0.6.43 spec/unit/helpers/data_helper_spec.rb
gooddata-0.6.42 spec/unit/helpers/data_helper_spec.rb
gooddata-0.6.41 spec/unit/helpers/data_helper_spec.rb
gooddata-0.6.40 spec/unit/helpers/data_helper_spec.rb
gooddata-0.6.39 spec/unit/helpers/data_helper_spec.rb
gooddata-0.6.38 spec/unit/helpers/data_helper_spec.rb
gooddata-0.6.37 spec/unit/helpers/data_helper_spec.rb
gooddata-0.6.36 spec/unit/helpers/data_helper_spec.rb
gooddata-0.6.35 spec/unit/helpers/data_helper_spec.rb
gooddata-0.6.34 spec/unit/helpers/data_helper_spec.rb
gooddata-0.6.33 spec/unit/helpers/data_helper_spec.rb
gooddata-0.6.32 spec/unit/helpers/data_helper_spec.rb
gooddata-0.6.31 spec/unit/helpers/data_helper_spec.rb
gooddata-0.6.30 spec/unit/helpers/data_helper_spec.rb