-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
102 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
require "installation/clients/inst_instsys_cleanup" | ||
Yast::InstInstsysCleanupClient.new.main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# encoding: utf-8 | ||
|
||
# ------------------------------------------------------------------------------ | ||
# Copyright (c) 2016 SUSE LLC, All Rights Reserved. | ||
# | ||
# This program is free software; you can redistribute it and/or modify it under | ||
# the terms of version 2 of the GNU General Public License as published by the | ||
# Free Software Foundation. | ||
# | ||
# This program is distributed in the hope that it will be useful, but WITHOUT | ||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
# | ||
# ------------------------------------------------------------------------------ | ||
|
||
require "yast" | ||
require "installation/instsys_cleaner" | ||
|
||
# This is a client wrapper around the InstsysCleaner class | ||
module Yast | ||
class InstInstsysCleanupClient < Client | ||
def main | ||
Installation::InstsysCleaner.make_clean | ||
|
||
:next | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#! /usr/bin/env rspec | ||
|
||
require_relative "./test_helper" | ||
|
||
require "installation/instsys_cleaner" | ||
|
||
describe Installation::InstsysCleaner do | ||
describe ".make_clean" do | ||
context "in the initial stage" do | ||
before do | ||
expect(Yast::Stage).to receive(:initial).and_return(true) | ||
expect(Yast::Mode).to receive(:installation).and_return(true) | ||
end | ||
|
||
it "removes the libzypp cache if the memory less than 640MB" do | ||
# 512MB RAM | ||
expect(Yast2::HwDetection).to receive(:memory).and_return(512 << 20) | ||
allow(subject.class).to receive(:unmount_kernel_modules) | ||
|
||
expect(FileUtils).to receive(:rm_rf).with(Installation::InstsysCleaner::LIBZYPP_CACHE_PATH) | ||
|
||
subject.class.make_clean | ||
end | ||
|
||
it "removes the kernel modules if the memory less than 1GB" do | ||
# 768MB RAM | ||
expect(Yast2::HwDetection).to receive(:memory).and_return(768 << 20) | ||
allow(subject.class).to receive(:cleanup_zypp_cache) | ||
|
||
expect(File).to receive(:exist?).with("/parts/mp_0000/lib/modules").and_return(true) | ||
|
||
subject.class.make_clean | ||
end | ||
|
||
it "does not remove anything if there is enough memory" do | ||
# 2GB RAM | ||
expect(Yast2::HwDetection).to receive(:memory).and_return(2 << 30) | ||
|
||
expect(subject.class).to_not receive(:cleanup_zypp_cache) | ||
expect(subject.class).to_not receive(:unmount_kernel_modules) | ||
|
||
subject.class.make_clean | ||
end | ||
end | ||
|
||
context "outside the initial stage" do | ||
before do | ||
expect(Yast::Stage).to receive(:initial).and_return(false) | ||
end | ||
|
||
it "does not do anything" do | ||
expect(subject.class).to_not receive(:cleanup_zypp_cache) | ||
expect(subject.class).to_not receive(:unmount_kernel_modules) | ||
|
||
subject.class.make_clean | ||
end | ||
end | ||
end | ||
end |