1 // Copyright 2008-2010 Victor Iacoban
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software distributed under
10 // the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
11 // either express or implied. See the License for the specific language governing permissions and
12 // limitations under the License.
13 package org.zmlx.hg4idea.test;
15 import com.intellij.openapi.vfs.VirtualFile;
16 import org.testng.Assert;
17 import org.testng.annotations.Test;
21 public class HgDeleteTestCase extends HgSingleUserTestCase {
24 public void testDeleteUnmodifiedFile() throws Exception {
25 VirtualFile file = createFileInCommand("a.txt", "new file content");
26 runHgOnProjectRepo("commit", "-m", "added file");
27 deleteFileInCommand(file);
28 verify(runHgOnProjectRepo("status"), HgTestOutputParser.removed("a.txt"));
32 public void testDeleteUnversionedFile() throws Exception {
33 VirtualFile file = makeFile(new File(myWorkingCopyDir.getPath(), "a.txt"));
34 verify(runHgOnProjectRepo("status"), HgTestOutputParser.unknown("a.txt"));
35 deleteFileInCommand(file);
36 Assert.assertFalse(file.exists());
40 public void testDeleteNewFile() throws Exception {
41 VirtualFile file = createFileInCommand("a.txt", "new file content");
42 deleteFileInCommand(file);
43 Assert.assertFalse(file.exists());
47 public void testDeleteModifiedFile() throws Exception {
48 VirtualFile file = createFileInCommand("a.txt", "new file content");
49 runHgOnProjectRepo("commit", "-m", "added file");
50 editFileInCommand(myProject, file, "even newer content");
51 verify(runHgOnProjectRepo("status"), HgTestOutputParser.modified("a.txt"));
52 deleteFileInCommand(file);
53 verify(runHgOnProjectRepo("status"), HgTestOutputParser.removed("a.txt"));
57 public void testDeleteDirWithFiles() throws Exception {
58 VirtualFile parent = createDirInCommand(myWorkingCopyDir, "com");
59 createFileInCommand(parent, "a.txt", "new file content");
60 runHgOnProjectRepo("commit", "-m", "added file");
61 deleteFileInCommand(parent);
62 verify(runHgOnProjectRepo("status"), HgTestOutputParser.removed("com", "a.txt"));