Sha256: 3b08a898f2eccdf5f6a780f99102727b3db225da226dd35a79666e32beb82cb1

Contents?: true

Size: 889 Bytes

Versions: 1

Compression:

Stored size: 889 Bytes

Contents

# encoding: utf-8
require 'spec_helper'
require "logstash/filters/jsonvalidate"

describe LogStash::Filters::Jsonvalidate do
  describe "Valid Json" do
    let(:config) do <<-CONFIG
      filter {
        jsonvalidate {
          test_fields => ['call', 'response']
        }
      }
    CONFIG
    end

    sample("call" => "{\"Marco\":\"polo\"}", "response" => "{\"herber\":\"hoover\"}", "tags" =>[]) do
      expect(subject).to include("tags")
      expect(subject['tags']).to eq([])
    end
  end

  describe "Invalid Json" do
    let(:config) do <<-CONFIG
      filter {
        jsonvalidate {
          test_fields => ['call', 'response']
        }
      }
    CONFIG
    end

    sample("call" => "{\"marco\":\"polo\"}", "response" => "totes not json", "tags" => []) do
      expect(subject).to include("tags")
      expect(subject['tags']).to include("not_json")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
logstash-filter-jsonvalidate-0.0.1 spec/filters/jsonvalidate_spec.rb