Skip to content

Commit c90b063

Browse files
committed
update feature test
1 parent 222c5f4 commit c90b063

2 files changed

Lines changed: 131 additions & 26 deletions

File tree

features/remove-project.feature

Lines changed: 125 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,62 @@
11
Feature: Remove a project from the manifest
22

3+
During the lifetime of a project, dependencies come and go. When a vendored
4+
library is no longer needed, *DFetch* can remove it from the manifest **and**
5+
delete the fetched files in one step with ``dfetch remove <name>``.
6+
7+
Background:
8+
Given a git repository "LibAlpha.git"
9+
And a git repository "LibBeta.git"
10+
And the manifest 'dfetch.yaml'
11+
"""
12+
manifest:
13+
version: '0.0'
14+
15+
projects:
16+
- name: lib-alpha
17+
url: some-remote-server/LibAlpha.git
18+
dst: ext/lib-alpha
19+
20+
- name: lib-beta
21+
url: some-remote-server/LibBeta.git
22+
dst: ext/lib-beta
23+
24+
"""
25+
And all projects are updated
26+
327
Scenario: Remove an existing project
428
Given the manifest 'dfetch.yaml'
529
"""
630
manifest:
731
version: '0.0'
832
933
projects:
10-
- name: ext/test-repo-tag
11-
url: https://github.com/dfetch-org/test-repo
12-
tag: v1
34+
- name: lib-alpha
35+
url: some-remote-server/LibAlpha.git
36+
dst: ext/lib-alpha
37+
38+
- name: lib-beta
39+
url: some-remote-server/LibBeta.git
40+
dst: ext/lib-beta
1341
1442
"""
15-
And all projects are updated
16-
When I run "dfetch remove ext/test-repo-tag"
43+
When I run "dfetch remove lib-alpha"
1744
Then the manifest 'dfetch.yaml' is replaced with
1845
"""
1946
manifest:
2047
version: '0.0'
2148
22-
projects: []
49+
projects:
50+
- name: lib-beta
51+
url: some-remote-server/LibBeta.git
52+
dst: ext/lib-beta
2353
2454
"""
25-
And the directory 'ext/test-repo-tag' should be removed from disk
55+
And the directory 'ext/lib-alpha' should be removed from disk
2656
And the output shows
2757
"""
28-
Dfetch (0.14.0)
29-
ext/test-repo-tag:
58+
Dfetch (0.13.0)
59+
lib-alpha:
3060
> removed
3161
"""
3262

@@ -37,19 +67,52 @@ Feature: Remove a project from the manifest
3767
version: '0.0'
3868
3969
projects:
40-
- name: project1
41-
url: https://github.com/dfetch-org/test-repo
42-
tag: v1
43-
dst: proj1
70+
- name: lib-alpha
71+
url: some-remote-server/LibAlpha.git
72+
dst: ext/lib-alpha
73+
74+
- name: lib-beta
75+
url: some-remote-server/LibBeta.git
76+
dst: ext/lib-beta
77+
78+
"""
79+
When I run "dfetch remove lib-alpha lib-beta"
80+
Then the manifest 'dfetch.yaml' is replaced with
81+
"""
82+
manifest:
83+
version: '0.0'
84+
85+
projects: []
86+
87+
"""
88+
And the directory 'ext/lib-alpha' should be removed from disk
89+
And the directory 'ext/lib-beta' should be removed from disk
90+
And the output shows
91+
"""
92+
Dfetch (0.13.0)
93+
lib-alpha:
94+
> removed
95+
lib-beta:
96+
> removed
97+
"""
98+
99+
Scenario: Removing a project that does not exist in the manifest is reported
100+
Given the manifest 'dfetch.yaml'
101+
"""
102+
manifest:
103+
version: '0.0'
104+
105+
projects:
106+
- name: lib-alpha
107+
url: some-remote-server/LibAlpha.git
108+
dst: ext/lib-alpha
44109
45-
- name: project3
46-
url: https://github.com/dfetch-org/test-repo
47-
tag: v1
48-
dst: proj3
110+
- name: lib-beta
111+
url: some-remote-server/LibBeta.git
112+
dst: ext/lib-beta
49113
50114
"""
51-
And all projects are updated
52-
When I run "dfetch remove project1 project2 project3"
115+
When I run "dfetch remove lib-alpha lib-unknown lib-beta"
53116
Then the manifest 'dfetch.yaml' is replaced with
54117
"""
55118
manifest:
@@ -58,15 +121,51 @@ Feature: Remove a project from the manifest
58121
projects: []
59122
60123
"""
61-
And the directory 'proj1' should be removed from disk
62-
And the directory 'proj3' should be removed from disk
124+
And the directory 'ext/lib-alpha' should be removed from disk
125+
And the directory 'ext/lib-beta' should be removed from disk
63126
And the output shows
64127
"""
65-
Dfetch (0.14.0)
66-
project2:
67-
> project 'project2' not found in manifest
68-
project1:
128+
Dfetch (0.13.0)
129+
lib-unknown:
130+
> project 'lib-unknown' not found in manifest
131+
lib-alpha:
132+
> removed
133+
lib-beta:
69134
> removed
70-
project3:
135+
"""
136+
137+
Scenario: Removing a project that was never fetched still removes it from the manifest
138+
Given the manifest 'dfetch.yaml'
139+
"""
140+
manifest:
141+
version: '0.0'
142+
143+
projects:
144+
- name: lib-gamma
145+
url: some-remote-server/LibBeta.git
146+
dst: ext/lib-gamma
147+
148+
- name: lib-alpha
149+
url: some-remote-server/LibAlpha.git
150+
dst: ext/lib-alpha
151+
152+
"""
153+
And the directory 'ext/lib-gamma' does not exist on disk
154+
When I run "dfetch remove lib-gamma"
155+
Then the manifest 'dfetch.yaml' is replaced with
156+
"""
157+
manifest:
158+
version: '0.0'
159+
160+
projects:
161+
- name: lib-alpha
162+
url: some-remote-server/LibAlpha.git
163+
dst: ext/lib-alpha
164+
165+
"""
166+
And the output shows
167+
"""
168+
Dfetch (0.13.0)
169+
lib-gamma:
71170
> removed
72171
"""

features/steps/generic_steps.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,3 +463,9 @@ def step_impl(context, path):
463463
def step_impl(_, path):
464464
"""Check if a directory is removed."""
465465
assert not os.path.exists(path), f"Directory {path} still exists!"
466+
467+
468+
@given("the directory '{path}' does not exist on disk")
469+
def step_impl(_, path):
470+
"""Assert that a directory has not been created."""
471+
assert not os.path.exists(path), f"Directory {path} exists but should not!"

0 commit comments

Comments
 (0)