Skip to content

Commit

Permalink
Fixes #36853 - Fix the tests that caused SIGKILL
Browse files Browse the repository at this point in the history
  • Loading branch information
lfu committed Oct 20, 2023
1 parent dc02aab commit 586edf6
Showing 1 changed file with 4 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,54 +32,17 @@ def teardown
end

def test_with_year_2024_1_1
Time.stubs(:now).returns(Time.utc(2024, 1, 1))
expire_soon = {"RHEL7" => {"maintenance_support" => Time.parse("2024-06-30")}, "RHEL6" => {"extended_support" => Time.parse("2024-06-30")}}
::Katello::RhelLifecycleStatus.expects(:lifecycles_expire_soon).returns(expire_soon)
@subject.expects(:hosts_with_index).with("RHEL6").returns([mock('rhel6')])
@subject.expects(:hosts_with_index).with("RHEL7").returns([mock('rhel7')])
@subject.deliver!
assert_equal 2, NotificationBlueprint.find_by(name: 'host_lifecycle_expire_soon').notifications.count
end

def test_with_year_2025_1_1
Time.stubs(:now).returns(Time.utc(2025, 1, 1))
@subject.deliver!
assert_equal 0, NotificationBlueprint.find_by(name: 'host_lifecycle_expire_soon').notifications.count
end

def test_with_year_2026_6_1
Time.stubs(:now).returns(Time.utc(2026, 6, 1))
@subject.deliver!
assert_equal 0, NotificationBlueprint.find_by(name: 'host_lifecycle_expire_soon').notifications.count
end

def test_with_year_2027_7_1
Time.stubs(:now).returns(Time.utc(2027, 7, 1))
@subject.expects(:hosts_with_index).with("RHEL7").returns([mock('rhel7')])
@subject.deliver!
assert_equal 1, NotificationBlueprint.find_by(name: 'host_lifecycle_expire_soon').notifications.count
end

def test_with_year_2028_6_1
Time.stubs(:now).returns(Time.utc(2028, 6, 1))
@subject.expects(:hosts_with_index).with("RHEL7").returns([mock('rhel7')])
@subject.expects(:hosts_with_index).with("RHEL8").returns([mock('rhel8')])
@subject.deliver!
assert_equal 2, NotificationBlueprint.find_by(name: 'host_lifecycle_expire_soon').notifications.count
end

def test_with_year_2029_6_1
Time.stubs(:now).returns(Time.utc(2029, 6, 1))
@subject.deliver!
assert_equal 0, NotificationBlueprint.find_by(name: 'host_lifecycle_expire_soon').notifications.count
end

def test_with_year_2030_6_1
Time.stubs(:now).returns(Time.utc(2030, 6, 1))
@subject.deliver!
assert_equal 0, NotificationBlueprint.find_by(name: 'host_lifecycle_expire_soon').notifications.count
end

def test_with_year_2031_6_1
Time.stubs(:now).returns(Time.utc(2031, 6, 1))
expire_soon = {"RHEL9" => {"maintenance_support" => Time.parse("2032-05-31")}, "RHEL8" => {"extended_support" => Time.parse("2032-05-31")}}
::Katello::RhelLifecycleStatus.expects(:lifecycles_expire_soon).returns(expire_soon)
@subject.expects(:hosts_with_index).with("RHEL8").returns([mock('rhel8')])
@subject.expects(:hosts_with_index).with("RHEL9").returns([mock('rhel9')])
@subject.deliver!
Expand Down

0 comments on commit 586edf6

Please sign in to comment.