2011-06-29 22:21:55 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2015-06-01 13:21:59 +02:00
|
|
|
describe 'strftime' do
|
2011-06-29 22:21:55 +02:00
|
|
|
it "should exist" do
|
2014-06-04 20:38:37 +02:00
|
|
|
expect(Puppet::Parser::Functions.function("strftime")).to eq("function_strftime")
|
2011-06-29 22:21:55 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should raise a ParseError if there is less than 1 arguments" do
|
2014-06-04 20:38:37 +02:00
|
|
|
expect { scope.function_strftime([]) }.to( raise_error(Puppet::ParseError))
|
2011-06-29 22:21:55 +02:00
|
|
|
end
|
|
|
|
|
2011-07-29 21:57:10 +02:00
|
|
|
it "using %s should be higher then when I wrote this test" do
|
2012-07-20 01:14:37 +02:00
|
|
|
result = scope.function_strftime(["%s"])
|
2014-06-04 20:38:37 +02:00
|
|
|
expect(result.to_i).to(be > 1311953157)
|
2011-07-29 21:57:10 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
it "using %s should be lower then 1.5 trillion" do
|
2012-07-20 01:14:37 +02:00
|
|
|
result = scope.function_strftime(["%s"])
|
2014-06-04 20:38:37 +02:00
|
|
|
expect(result.to_i).to(be < 1500000000)
|
2011-07-29 21:57:10 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should return a date when given %Y-%m-%d" do
|
2012-07-20 01:14:37 +02:00
|
|
|
result = scope.function_strftime(["%Y-%m-%d"])
|
2014-06-04 20:38:37 +02:00
|
|
|
expect(result).to match(/^\d{4}-\d{2}-\d{2}$/)
|
2011-07-29 21:57:10 +02:00
|
|
|
end
|
2011-06-29 22:21:55 +02:00
|
|
|
end
|