... |
... |
@@ -123,6 +123,58 @@ def test_open_force(cli, tmpdir, datafiles, kind): |
123
|
123
|
result.assert_success()
|
124
|
124
|
|
125
|
125
|
|
|
126
|
+@pytest.mark.datafiles(DATA_DIR)
|
|
127
|
+@pytest.mark.parametrize("kind", repo_kinds)
|
|
128
|
+def test_open_force_open(cli, tmpdir, datafiles, kind):
|
|
129
|
+ element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, kind, False)
|
|
130
|
+
|
|
131
|
+ # Assert the workspace dir exists
|
|
132
|
+ assert os.path.exists(workspace)
|
|
133
|
+
|
|
134
|
+ # Now open the workspace again with --force, this should happily succeed
|
|
135
|
+ result = cli.run(project=project, args=[
|
|
136
|
+ 'workspace', 'open', '--force', element_name, workspace
|
|
137
|
+ ])
|
|
138
|
+ result.assert_success()
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+@pytest.mark.datafiles(DATA_DIR)
|
|
142
|
+@pytest.mark.parametrize("kind", repo_kinds)
|
|
143
|
+def test_open_force_different_workspace(cli, tmpdir, datafiles, kind):
|
|
144
|
+ element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, kind, False, "-alpha")
|
|
145
|
+
|
|
146
|
+ # Assert the workspace dir exists
|
|
147
|
+ assert os.path.exists(workspace)
|
|
148
|
+
|
|
149
|
+ hello_path = os.path.join(workspace, 'usr', 'bin', 'hello')
|
|
150
|
+ hello1_path = os.path.join(workspace, 'usr', 'bin', 'hello1')
|
|
151
|
+
|
|
152
|
+ tmpdir = os.path.join(str(tmpdir), "-beta")
|
|
153
|
+ shutil.move(hello_path, hello1_path)
|
|
154
|
+ element_name2, project2, workspace2 = open_workspace(cli, tmpdir, datafiles, kind, False, "-beta")
|
|
155
|
+
|
|
156
|
+ # Assert the workspace dir exists
|
|
157
|
+ assert os.path.exists(workspace2)
|
|
158
|
+
|
|
159
|
+ # Assert that workspace 1 contains the modified file
|
|
160
|
+ assert os.path.exists(hello1_path)
|
|
161
|
+
|
|
162
|
+ # Assert that workspace 2 contains the unmodified file
|
|
163
|
+ assert os.path.exists(os.path.join(workspace2, 'usr', 'bin', 'hello'))
|
|
164
|
+
|
|
165
|
+ # Now open the workspace again with --force, this should happily succeed
|
|
166
|
+ result = cli.run(project=project, args=[
|
|
167
|
+ 'workspace', 'open', '--force', element_name2, workspace
|
|
168
|
+ ])
|
|
169
|
+
|
|
170
|
+ # Assert that the file in workspace 1 has been replaced
|
|
171
|
+ # With the file from workspace 2
|
|
172
|
+ assert os.path.exists(hello_path)
|
|
173
|
+ assert not os.path.exists(hello1_path)
|
|
174
|
+
|
|
175
|
+ result.assert_success()
|
|
176
|
+
|
|
177
|
+
|
126
|
178
|
@pytest.mark.datafiles(DATA_DIR)
|
127
|
179
|
@pytest.mark.parametrize("kind", repo_kinds)
|
128
|
180
|
def test_close(cli, tmpdir, datafiles, kind):
|