3 test_description
='Test branch protection'
7 test_expect_success
'Initialize branch' '
9 stg branch --create foo &&
16 test_expect_success
'Invald num args to protect' '
17 command_error stg branch --protect foo bar 2>&1 |
18 grep "incorrect number of arguments"
21 test_expect_success
'Protect branch' '
25 test_expect_success
'List protected' '
27 grep -E "> sp[[:space:]]+foo"
30 test_expect_success
'Protect idempotency' '
31 stg branch --protect foo
34 test_expect_success
'Attempt cleanup protected' '
35 command_error stg branch --cleanup 2>&1 |
36 grep "This branch is protected"
39 test_expect_success
'Attempt delete protected' '
41 command_error stg branch --delete foo 2>&1 |
42 grep "This branch is protected"
45 test_expect_success
'Invalid num arts to unprotect' '
46 command_error stg branch --unprotect foo bar 2>&1 |
47 grep "incorrect number of arguments"
50 test_expect_success
'Unprotect branch' '
51 stg branch --unprotect foo
54 test_expect_success
'List unprotected' '
56 grep -E " s[[:space:]]+foo"
59 test_expect_success
'Unprotect idempotency' '
61 stg branch --unprotect &&
63 grep -E "> s[[:space:]]+foo"
66 test_expect_success
'Cleanup unprotected' '
71 test_expect_success
'Protect uninitialized branch' '
72 command_error stg branch --protect 2>&1 |
73 grep -E "is not controlled by StGit"
76 test_expect_success
'Protect uninitialized branch' '
77 command_error stg branch --unprotect 2>&1 |
78 grep -E "is not controlled by StGit"
81 test_expect_success
'Delete unprotected' '
83 stg branch --delete foo