1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-01-11 16:36:14 +01:00

Add behave tests for 'createrequest -a submit --supersede' and 'submitrequest --supersede'

This commit is contained in:
Daniel Mach 2023-10-04 10:26:31 +02:00
parent b47468abf3
commit b3743b183c
3 changed files with 91 additions and 2 deletions

View File

@ -0,0 +1,37 @@
Feature: `osc createrequest` command
# common steps for all scenarios
Background:
Given I set working directory to "{context.osc.temp}"
And I execute osc with args "branch test:factory/test-pkgA"
# the package gets forked from the devel project!
And I execute osc with args "co home:Admin:branches:test:devel/test-pkgA"
And I set working directory to "{context.osc.temp}/home:Admin:branches:test:devel/test-pkgA"
@destructive
Scenario: Run `osc createrequest`
When I copy file "{context.fixtures}/pac/test-pkgA-1.spec" to "{context.osc.temp}/home:Admin:branches:test:devel/test-pkgA/new_file"
And I execute osc with args "add new_file"
And I execute osc with args "ci -m 'commit description'"
And I execute osc with args "createrequest -a submit -m 'request description'"
Then the exit code is 0
@destructive
Scenario: Run `osc createrequest --supersede`
Given I copy file "{context.fixtures}/pac/test-pkgA-1.spec" to "{context.osc.temp}/home:Admin:branches:test:devel/test-pkgA/new_file"
And I execute osc with args "add new_file"
And I execute osc with args "ci -m 'commit description'"
And I execute osc with args "createrequest -a submit -m 'request description'"
And the exit code is 0
And I execute osc with args "api /request/1"
And stdout doesn't contain "<state name=\"superseded\">"
When I copy file "{context.fixtures}/pac/test-pkgA-1.spec" to "{context.osc.temp}/home:Admin:branches:test:devel/test-pkgA/another_file"
And I execute osc with args "add new_file"
And I execute osc with args "ci -m 'commit description'"
And I execute osc with args "createrequest -a submit -m 'request description' --supersede 1"
Then the exit code is 0
And I execute osc with args "api /request/1"
And stdout contains "<state name=\"superseded\".*superseded_by=\"2\">"

View File

@ -1,5 +1,6 @@
import errno
import os
import re
import shutil
import subprocess
@ -86,14 +87,28 @@ def run_in_context(context, cmd, can_fail=False, **run_args):
def step_impl(context, text):
if re.search(text.format(context=context), context.cmd_stdout):
return
raise AssertionError("Stdout doesn't contain: %s" % text)
raise AssertionError("Stdout doesn't contain expected pattern: %s" % text)
@behave.step("stdout doesn't contain \"{text}\"")
def step_impl(context, text):
if not re.search(text.format(context=context), context.cmd_stdout):
return
raise AssertionError("Stdout is not supposed to contain pattern: %s" % text)
@behave.step("stderr contains \"{text}\"")
def step_impl(context, text):
if re.search(text.format(context=context), context.cmd_stderr):
return
raise AssertionError("Stderr doesn't contain: %s" % text)
raise AssertionError("Stderr doesn't contain expected pattern: %s" % text)
@behave.step("stderr doesn't contain \"{text}\"")
def step_impl(context, text):
if not re.search(text.format(context=context), context.cmd_stderr):
return
raise AssertionError("Stderr is not supposed to contain pattern: %s" % text)
@behave.step("stdout is")

View File

@ -0,0 +1,37 @@
Feature: `osc submitrequest` command
# common steps for all scenarios
Background:
Given I set working directory to "{context.osc.temp}"
And I execute osc with args "branch test:factory/test-pkgA"
# the package gets forked from the devel project!
And I execute osc with args "co home:Admin:branches:test:devel/test-pkgA"
And I set working directory to "{context.osc.temp}/home:Admin:branches:test:devel/test-pkgA"
@destructive
Scenario: Run `osc submitrequest`
When I copy file "{context.fixtures}/pac/test-pkgA-1.spec" to "{context.osc.temp}/home:Admin:branches:test:devel/test-pkgA/new_file"
And I execute osc with args "add new_file"
And I execute osc with args "ci -m 'commit description'"
And I execute osc with args "submitrequest -m 'request description'"
Then the exit code is 0
@destructive
Scenario: Run `osc submitrequest --supersede`
Given I copy file "{context.fixtures}/pac/test-pkgA-1.spec" to "{context.osc.temp}/home:Admin:branches:test:devel/test-pkgA/new_file"
And I execute osc with args "add new_file"
And I execute osc with args "ci -m 'commit description'"
And I execute osc with args "submitrequest -m 'request description'"
And the exit code is 0
And I execute osc with args "api /request/1"
And stdout doesn't contain "<state name=\"superseded\">"
When I copy file "{context.fixtures}/pac/test-pkgA-1.spec" to "{context.osc.temp}/home:Admin:branches:test:devel/test-pkgA/another_file"
And I execute osc with args "add new_file"
And I execute osc with args "ci -m 'commit description'"
And I execute osc with args "submitrequest -m 'request description' --supersede 1"
Then the exit code is 0
And I execute osc with args "api /request/1"
And stdout contains "<state name=\"superseded\".*superseded_by=\"2\">"