Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: fix test that was failing due to time differences
Browse files Browse the repository at this point in the history
adamcooke committed Feb 15, 2024
1 parent ac179d2 commit 610e722
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions spec/lib/postal/smtp_server/client/data_spec.rb
Original file line number Diff line number Diff line change
@@ -50,10 +50,10 @@ module SMTPServer
client.handle("HELO test.example.com")
client.handle("MAIL FROM: test@test.com")
client.handle("RCPT TO: #{route.name}@#{route.domain.name}")
client.handle("DATA")
end

it "logs headers" do
client.handle("DATA")
client.handle("Subject: Test")
client.handle("From: test@test.com")
client.handle("To: test1@example.com")
@@ -66,17 +66,20 @@ module SMTPServer
end

it "logs content" do
client.handle("Subject: Test")
client.handle("")
client.handle("This is some content for the message.")
client.handle("It will keep going.")
expect(client.instance_variable_get("@data")).to eq <<~DATA
Received: from test.example.com (1.2.3.4 [1.2.3.4]) by #{Postal.config.dns.smtp_server_hostname} with SMTP; #{Time.now.utc.rfc2822}\r
Subject: Test\r
\r
This is some content for the message.\r
It will keep going.\r
DATA
Timecop.freeze do
client.handle("DATA")
client.handle("Subject: Test")
client.handle("")
client.handle("This is some content for the message.")
client.handle("It will keep going.")
expect(client.instance_variable_get("@data")).to eq <<~DATA
Received: from test.example.com (1.2.3.4 [1.2.3.4]) by #{Postal.config.dns.smtp_server_hostname} with SMTP; #{Time.now.utc.rfc2822}\r
Subject: Test\r
\r
This is some content for the message.\r
It will keep going.\r
DATA
end
end
end
end

0 comments on commit 610e722

Please sign in to comment.