Sha256: 35dfbadebab72bc7de3660cbddf2a018c070643005050bdad3615fc08330817b

Contents?: true

Size: 880 Bytes

Versions: 1

Compression:

Stored size: 880 Bytes

Contents

require 'spec_helper'

describe Magellan::LogFunnel do
  before do
    @command = [ "/bin/echo", "foo" ]
    @argv = [
      "--fluentd", "http://fluentd.example:8888",
      "--project", "PROJECT1",
      "--stage", "STAGE1",
      "--worker-version", "1.0",
      "--container", "CONTAINER1",
    ] + @command
    @funnel = Magellan::LogFunnel.new(@argv)
    # stub Net::HTTP.post_form
    @now = Time.now
    allow(@funnel).to receive(:now).and_return(@now)
    expect(Net::HTTP).to receive(:post_form).with(URI("http://fluentd.example:8888/worker_logs.PROJECT1.STAGE1"),
                                                  json: JSON.generate({
      time: @now.to_i,
      project: "PROJECT1",
      stage: "STAGE1",
      version: "1.0",
      container: "CONTAINER1",
      message: "foo"
    }))
  end
  it 'can handle stdout' do
    expect(@funnel.run).to eql(0)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
magellan-log-funnel-1.0.0 spec/magellan/log_funnel_spec.rb