Pigeon-Ruby/spec/pigeon/bundle_spec.rb

36 lines
1.1 KiB
Ruby
Raw Normal View History

require "spec_helper"
RSpec.describe Pigeon::Message do
before(:each) do
2020-04-01 13:07:39 +00:00
p = Pigeon::DEFAULT_BUNDLE_PATH
File.delete(p) if File.file?(p)
Pigeon::Storage.reset
Pigeon::LocalIdentity.reset
end
2020-04-01 13:07:39 +00:00
def create_fake_messages
(1..10)
.to_a
2020-04-01 13:07:39 +00:00
.map do |n| { "foo" => ["bar", "123", SecureRandom.uuid].sample } end
.map do |d| Pigeon::Helpers.create_message(SecureRandom.uuid, d) end
2020-04-01 13:07:39 +00:00
end
it "creates a bundle" do
expected_bundle = create_fake_messages.map(&:render).join("\n\n") + "\n"
Pigeon::Bundle.create
actual_bundle = File.read(Pigeon::DEFAULT_BUNDLE_PATH)
expect(expected_bundle).to eq(actual_bundle)
end
2020-04-01 13:07:39 +00:00
it "debugs a problem" do
seed = "\xA3@\x12\xA6\x8Cl\x83\xF5)\x97\xED\xE67\x91\xAD\xFD\xCFf\xF4(\xEF\x81P\xBBD\xF7\x8C\xF7\x8D\xC0\xA9\f"
ident = Pigeon::LocalIdentity.new(seed)
Pigeon::LocalIdentity.instance_variable_set(:@current, ident)
public_key = "@NYTrqYYN2ffTqFyPCUULjhhUkfbY9LorpWYMoMpsOO4=.ed25519"
expect(Pigeon::LocalIdentity.current.public_key).to eq(public_key)
2020-04-01 13:07:39 +00:00
create_fake_messages
Pigeon::Bundle.create
Pigeon::Bundle.ingest
2020-04-01 13:07:39 +00:00
end
end