2020-03-15 16:51:13 +00:00
|
|
|
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)
|
2020-03-15 16:51:13 +00:00
|
|
|
Pigeon::Storage.reset
|
2020-03-24 12:39:32 +00:00
|
|
|
Pigeon::LocalIdentity.reset
|
2020-03-15 16:51:13 +00:00
|
|
|
end
|
|
|
|
|
2020-04-01 13:07:39 +00:00
|
|
|
def create_fake_messages
|
|
|
|
(1..10)
|
2020-03-15 16:51:13 +00:00
|
|
|
.to_a
|
2020-04-01 13:07:39 +00:00
|
|
|
.map do |n| { "foo" => ["bar", "123", SecureRandom.uuid].sample } end
|
2020-04-01 13:41:41 +00:00
|
|
|
.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"
|
2020-03-15 16:51:13 +00:00
|
|
|
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)
|
2020-04-01 13:41:41 +00:00
|
|
|
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
|
2020-04-01 13:25:27 +00:00
|
|
|
Pigeon::Bundle.ingest
|
2020-04-01 13:07:39 +00:00
|
|
|
end
|
2020-03-15 16:51:13 +00:00
|
|
|
end
|