Sha256: 05f483a95653f247e6d95df23bb9e0b9248265491ccd942317a9271371b2d85c
Contents?: true
Size: 1.16 KB
Versions: 3
Compression:
Stored size: 1.16 KB
Contents
# frozen_string_literal: true require 'open3' require 'climate_control' require 'timeout' describe 'bin/datadog_backup' do # Contract Or[nil,String] => self def run_bin(args = '', input = nil) status = nil output = '' cmd = "bin/datadog_backup #{args}" Open3.popen2e(cmd) do |i, oe, t| pid = t.pid if input i.puts input i.close end Timeout.timeout(2.0) do oe.each do |v| output += v end end rescue Timeout::Error LOGGER.warn "Timing out #{t.inspect} after 2 second" Process.kill(15, pid) ensure status = t.value end [output, status] end required_vars = %w[ DATADOG_API_KEY DATADOG_APP_KEY ] before do required_vars.each do |v| ClimateControl.env[v] = v.downcase end end required_vars.map do |v| it "dies unless given ENV[#{v}]" do ClimateControl.env[v] = nil _, status = run_bin('backup') expect(status).not_to be_success end end it 'supplies help' do out_err, status = run_bin('--help') expect(out_err).to match(/Usage: datadog_backup/) expect(status).to be_success end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
datadog_backup-1.0.4 | spec/datadog_backup_bin_spec.rb |
datadog_backup-1.0.3 | spec/datadog_backup_bin_spec.rb |
datadog_backup-1.0.2 | spec/datadog_backup_bin_spec.rb |