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.annotations.Test;
20 public class HgRenameTestCase extends HgAbstractTestCase {
23 public void testRenameUnmodifiedFile() throws Exception {
24 VirtualFile file = createFileInCommand("a.txt", "new file content");
25 runHgOnProjectRepo("commit", "-m", "added file");
26 renameFileInCommand(file, "b.txt");
27 verify(runHgOnProjectRepo("status"), added("b.txt"), removed("a.txt"));
31 public void testRenameModifiedFile() throws Exception {
32 VirtualFile file = createFileInCommand("a.txt", "new file content");
33 runHgOnProjectRepo("commit", "-m", "added file");
34 editFileInCommand(myProject, file, "modified new file content");
35 verify(runHgOnProjectRepo("status"), modified("a.txt"));
36 renameFileInCommand(file, "b.txt");
37 verify(runHgOnProjectRepo("status"), added("b.txt"), removed("a.txt"));
41 public void testRenameNewFile() throws Exception {
42 VirtualFile file = createFileInCommand("a.txt", "new file content");
43 renameFileInCommand(file, "b.txt");
44 verify(runHgOnProjectRepo("status"), added("b.txt"));
48 public void testRenameRenamedFile() throws Exception {
49 VirtualFile file = createFileInCommand("a.txt", "new file content");
50 runHgOnProjectRepo("commit", "-m", "added file");
51 renameFileInCommand(file, "b.txt");
52 renameFileInCommand(file, "c.txt");
53 verify(runHgOnProjectRepo("status"), added("c.txt"), removed("a.txt"));
57 public void testRenameVersionedFolder() throws Exception {
58 VirtualFile parent = createDirInCommand(myWorkingCopyDir, "com");
59 createFileInCommand(parent, "a.txt", "new file content");
60 runHgOnProjectRepo("commit", "-m", "added file");
61 renameFileInCommand(parent, "org");
62 verify(runHgOnProjectRepo("status"), added("org", "a.txt"), removed("com", "a.txt"));
66 public void testRenameUnversionedFolder() throws Exception {
67 VirtualFile parent = createDirInCommand(myWorkingCopyDir, "com");
69 File unversionedFile = new File(parent.getPath(), "a.txt");
70 makeFile(unversionedFile);
71 verify(runHgOnProjectRepo("status"), unknown("com", "a.txt"));
73 renameFileInCommand(parent, "org");
74 verify(runHgOnProjectRepo("status"), unknown("org", "a.txt"));
78 public void testRenameUnversionedFile() throws Exception {
79 File unversionedFile = new File(myWorkingCopyDir.getPath(), "a.txt");
80 VirtualFile file = makeFile(unversionedFile);
81 verify(runHgOnProjectRepo("status"), unknown("a.txt"));
83 renameFileInCommand(file, "b.txt");
84 verify(runHgOnProjectRepo("status"), unknown("b.txt"));