diff --git a/dnf-docker-test/features/history-1.feature b/dnf-docker-test/features/history-1.feature new file mode 100644 index 0000000000..2f74e1b807 --- /dev/null +++ b/dnf-docker-test/features/history-1.feature @@ -0,0 +1,72 @@ +Feature: DNF/Behave test Transaction history - base + + Scenario: Simple transaction + Given I use the repository "test-1" + When I execute "dnf" command "install -y TestA" with "success" + Then transaction changes are as follows + | State | Packages | + | installed | TestA, TestB | + When I execute "dnf" command "history" with "success" + Then the history should contain command "install -y TestA" and action "Install" with "2" packages + + Scenario: Undo last transaction + Given I use the repository "test-1" + When I execute "dnf" command "history undo last -y" with "success" + Then transaction changes are as follows + | State | Packages | + | removed | TestA, TestB | + When I execute "dnf" command "history" with "success" + Then the history should contain command "history undo last -y" and action "Erase" with "2" packages + + Scenario: Undo transaction last 2 + Given I use the repository "test-1" + When I execute "dnf" command "history undo last -y" with "success" + Then transaction changes are as follows + | State | Packages | + | installed | TestA, TestB | + When I execute "dnf" command "history" with "success" + Then the history should contain command "history undo last -y" and action "Install" with "2" packages + + Scenario: Undo transaction last-2 + Given I use the repository "test-1" + When I execute "dnf" command "history undo last-2 -y" with "success" + Then transaction changes are as follows + | State | Packages | + | removed | TestA, TestB | + When I execute "dnf" command "history" with "success" + Then the history should contain command "history undo last-2 -y" and action "Erase" with "2" packages + + Scenario: Redo transaction last + Given I use the repository "test-1" + When I execute "dnf" command "install -y TestA" with "success" + Then transaction changes are as follows + | State | Packages | + | installed | TestA, TestB | + When I execute "dnf" command "remove -y TestA" with "success" + Then transaction changes are as follows + | State | Packages | + | removed | TestA, TestB | + When I execute "dnf" command "history redo last-1 -y" with "success" + Then transaction changes are as follows + | State | Packages | + | installed | TestA, TestB | + When I execute "dnf" command "history" with "success" + Then the history should contain command "history redo last-1 -y" and action "Install" with "2" packages + When I execute "dnf" command "history redo last-1 -y" with "success" + Then transaction changes are as follows + | State | Packages | + | removed | TestA, TestB | + When I execute "dnf" command "history" with "success" + Then the history should contain command "history redo last-1 -y" and action "Remove" with "2" packages + + Scenario: Update packages + Given I use the repository "test-1" + When I execute "dnf" command "install -y TestA TestD TestH" with "success" + Given I use the repository "upgrade_1" + When I execute "dnf" command "update -y" with "success" + Then transaction changes are as follows + | State | Packages | + | installed | TestD, TestE, TestA, TestB, TestH | + | removed | TestA, TestB, TestD, TestE, TestH | + When I execute "dnf" command "history" with "success" + Then the history should contain command "update -y" and action "Update" with "5" package diff --git a/dnf-docker-test/features/steps/history_steps.py b/dnf-docker-test/features/steps/history_steps.py new file mode 100644 index 0000000000..6fce5b1802 --- /dev/null +++ b/dnf-docker-test/features/steps/history_steps.py @@ -0,0 +1,21 @@ +from behave import then +from behave import when +from behave import given + +@then('the history should contain command "{cmdline}" and action "{action}" with "{altered}" package') +@then('the history should contain command "{cmdline}" and action "{action}" with "{altered}" packages') +def then_history_is(context, cmdline, action, altered): + lines = context.cmd_output.split('\n') + assert len(lines) > 3, 'No output' + del lines[:3] + match = False + for line in lines: + columns = line.split('|') + words = [word.strip() for word in columns] + # last member can be e.g. "1 >" + words += words[-1].split() + if set([cmdline, action, altered]).issubset(set(words)): + match = True + break + assert match, '''Command "{}" and action "{}" with "{}" packages not matched! + {}'''.format(cmdline, action, altered, context.cmd_output)