Sha256: 195079d824607852964792ad0995ca73ef6c6ea739f070991cbc9f946e3c33b3
Contents?: true
Size: 1.89 KB
Versions: 14
Compression:
Stored size: 1.89 KB
Contents
require 'spec_helper' require 'flydata/api_client' require_relative '../helper_shared_context' require 'flydata/helper/action/send_logs' module Flydata module Helper module Action describe SendLogs do include_context 'helper context' let(:agent) { double("agent") } let(:api_client) do a = double("api_client") allow(a).to receive(:agent).and_return(agent) a end let(:send_log_action) do allow(ApiClient).to receive(:instance).and_return(api_client) described_class.new(config) end let(:action_config) { %Q|{"num_of_lines" : "10"}| } let(:action_info) do { id: 101, config: action_config, config_hash: JSON.parse(action_config, symbolize_names: true), } end describe "#execute" do before do File.open(FLYDATA_LOG, 'w') do |f| 0.upto(500) do |i| f.write("line#{i}\n") end end end context "action config does not have num_of_lines property" do it "posts default number of lines to api_client" do expect(agent).to receive(:send_logs) do |action_id, logs| expect(action_id).to eq(101) expect(logs.count("\n")).to eq(SendLogs::DEFAULT_NUM_OF_LINES) end send_log_action.execute({id:101, config: nil}) end end context "action config has num_of_lines property" do it "posts configured number of lines to api_client" do expect(agent).to receive(:send_logs) do |action_id, logs| expect(action_id).to eq(101) expect(logs.count("\n")).to eq(10) end send_log_action.execute(action_info) end end end end end end end
Version data entries
14 entries across 14 versions & 1 rubygems