Sha256: f5b7dac383dc0faa99047e0ba9ddaec7fe77741a068fb8065778801b82892236

Contents?: true

Size: 1.04 KB

Versions: 3

Compression:

Stored size: 1.04 KB

Contents

require 'spec_helper'

describe Diagnostic::Collection do
  def sample_data consistent = true
    node_a_data = Diagnostic::Collection.pack(include_ip=false){'A'}
    data = {
      'NodeA' => node_a_data,
      'NodeB' => node_a_data,
    }
    return data if consistent
    data + {'NodeB' => {'Base' => Diagnostic::Collection.error('B')}}
  end

  it 'all diagnostics in diagnostics class attribute are generated' do
    diags = [Diagnostic::Version, Diagnostic::Environment]
    expected = diags.map{|d| d.generate}.reduce(:deep_merge)
    Diagnostic::Collection.diagnostics = diags
    expect(Diagnostic::Collection.generate).to eq(expected)
  end

  it 'declares data consistency via status consistency' do
    a = sample_data
    b = sample_data + {
      'NodeB' => Diagnostic::Collection.pack(include_ip=false){'B'}
    }
    c = sample_data(consistent=false)

    expect(Diagnostic::Collection.consistent?(a)).to eq(true)
    expect(Diagnostic::Collection.consistent?(b)).to eq(true)
    expect(Diagnostic::Collection.consistent?(c)).to eq(false)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
marty-1.1.8 spec/models/diagnostic/collection_spec.rb
marty-1.1.7 spec/models/diagnostic/collection_spec.rb
marty-1.1.6 spec/models/diagnostic/collection_spec.rb