generate_parsed_data

in spec/chef/cookbooks/consul/libraries/failover_helper_spec.rb [35:74]


  def generate_parsed_data(unhealthy_primary: false, multiple_primaries: false)
    parsed_data = []
    nodes = [primary_node, follower_node_01, follower_node_02]

    nodes.push(splitbrain_primary_node) if multiple_primaries

    nodes.each do |node|
      if node.leader?
        leader_status = "passing"
        health = unhealthy_primary ? "failing" : "passing"
      else
        leader_status = "warning"
        health = "passing"
      end

      node_info = {
        "Node" => {
          "Node" => node.name,
          "Address" => node.address
        },
        "Checks" => [
          {
            "Node" => node.name,
            "CheckID" => "serfHealth",
            "Status" => health
          },
          {
            "Node" => node.name,
            "CheckID" => "example_service",
            "Status" => leader_status
          }
        ]
      }

      parsed_data.push(node_info)
    end

    parsed_data
  end