Skip to content

Commit

Permalink
Fix for the new yast2-core (#526)
Browse files Browse the repository at this point in the history
* Changes

* Fixed test - mock all used Pkg callbacks functions

* Code review fix: send() is not needed
  • Loading branch information
lslezak committed Jan 5, 2017
1 parent 432c2df commit 75a9162
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 5 deletions.
96 changes: 92 additions & 4 deletions library/packages/test/file_conflict_callbacks_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,94 @@ def CallbackFileConflictReport(func)
def CallbackFileConflictFinish(func)
@fc_finish = func
end

# run this command in "irb -ryast" to obtain the method names:
# Yast.import "Pkg"; Yast::Pkg.methods.select {|m| m.to_s.start_with?("Callback")}
# (Remove the methods which are defined above.)
MOCK_METHODS = [
:CallbackAcceptFileWithoutChecksum,
:CallbackAcceptUnknownDigest,
:CallbackAcceptUnknownGpgKey,
:CallbackAcceptUnsignedFile,
:CallbackAcceptVerificationFailed,
:CallbackAcceptWrongDigest,
:CallbackAuthentication,
:CallbackDestDownload,
:CallbackDoneDownload,
:CallbackDonePackage,
:CallbackDoneProvide,
:CallbackDoneRefresh,
:CallbackDoneScanDb,
:CallbackErrorScanDb,
:CallbackFinishDeltaApply,
:CallbackFinishDeltaDownload,
:CallbackImportGpgKey,
:CallbackInitDownload,
:CallbackMediaChange,
:CallbackMessage,
:CallbackNotifyConvertDb,
:CallbackNotifyRebuildDb,
:CallbackPkgGpgCheck,
:CallbackProblemDeltaApply,
:CallbackProblemDeltaDownload,
:CallbackProcessDone,
:CallbackProcessNextStage,
:CallbackProcessProgress,
:CallbackProcessStart,
:CallbackProgressConvertDb,
:CallbackProgressDeltaApply,
:CallbackProgressDeltaDownload,
:CallbackProgressDownload,
:CallbackProgressPackage,
:CallbackProgressProvide,
:CallbackProgressRebuildDb,
:CallbackProgressReportEnd,
:CallbackProgressReportProgress,
:CallbackProgressReportStart,
:CallbackProgressScanDb,
:CallbackResolvableReport,
:CallbackScriptFinish,
:CallbackScriptProblem,
:CallbackScriptProgress,
:CallbackScriptStart,
:CallbackSourceChange,
:CallbackSourceCreateDestroy,
:CallbackSourceCreateEnd,
:CallbackSourceCreateError,
:CallbackSourceCreateInit,
:CallbackSourceCreateProgress,
:CallbackSourceCreateStart,
:CallbackSourceProbeEnd,
:CallbackSourceProbeError,
:CallbackSourceProbeFailed,
:CallbackSourceProbeProgress,
:CallbackSourceProbeStart,
:CallbackSourceProbeSucceeded,
:CallbackSourceReportDestroy,
:CallbackSourceReportEnd,
:CallbackSourceReportError,
:CallbackSourceReportInit,
:CallbackSourceReportProgress,
:CallbackSourceReportStart,
:CallbackStartConvertDb,
:CallbackStartDeltaApply,
:CallbackStartDeltaDownload,
:CallbackStartDownload,
:CallbackStartPackage,
:CallbackStartProvide,
:CallbackStartRebuildDb,
:CallbackStartRefresh,
:CallbackStartScanDb,
:CallbackStopConvertDb,
:CallbackStopRebuildDb,
:CallbackTrustedKeyAdded,
:CallbackTrustedKeyRemoved
].freeze

MOCK_METHODS.each do |method|
# mock empty methods with a single argument
define_method(method) { |arg| }
end
end

describe Packages::FileConflictCallbacks do
Expand All @@ -42,10 +130,10 @@ def CallbackFileConflictFinish(func)

describe ".register" do
it "calls the Pkg methods for registering the file conflicts handlers" do
expect(dummy_pkg).to receive(:CallbackFileConflictStart)
expect(dummy_pkg).to receive(:CallbackFileConflictProgress)
expect(dummy_pkg).to receive(:CallbackFileConflictReport)
expect(dummy_pkg).to receive(:CallbackFileConflictFinish)
expect(dummy_pkg).to receive(:CallbackFileConflictStart).at_least(:once)
expect(dummy_pkg).to receive(:CallbackFileConflictProgress).at_least(:once)
expect(dummy_pkg).to receive(:CallbackFileConflictReport).at_least(:once)
expect(dummy_pkg).to receive(:CallbackFileConflictFinish).at_least(:once)

Packages::FileConflictCallbacks.register
end
Expand Down
7 changes: 7 additions & 0 deletions package/yast2.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Thu Jan 5 08:06:25 UTC 2017 - lslezak@suse.cz

- Fixed tests to pass with the latest yast2-core package
(related to the bsc#932331 fix)
- 3.2.10

-------------------------------------------------------------------
Tue Dec 20 16:28:45 UTC 2016 - igonzalezsosa@suse.com

Expand Down
2 changes: 1 addition & 1 deletion package/yast2.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: yast2
Version: 3.2.9
Version: 3.2.10
Release: 0
Summary: YaST2 - Main Package
License: GPL-2.0
Expand Down

0 comments on commit 75a9162

Please sign in to comment.