mirror of
https://github.com/x-motemen/ghq.git
synced 2026-09-10 07:26:27 -04:00
fix(test): add testcase and fix testcase
This commit is contained in:
parent
f6b96648d8
commit
9201500760
|
|
@ -41,19 +41,25 @@ func TestRmCommand(t *testing.T) {
|
|||
name: "simple",
|
||||
input: []string{"rm", "motemen/ghqq"},
|
||||
setup: func(t *testing.T) {
|
||||
f := filepath.Join(tmpd, "github.com", "motemen", "ghqq", "README.md")
|
||||
if err := os.MkdirAll(filepath.Dir(f), 0755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(f, []byte("test"), 0644); err != nil {
|
||||
if err := os.MkdirAll(filepath.Join(tmpd, "github.com", "motemen", "ghqq", ".git"), 0755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
},
|
||||
expectErr: false,
|
||||
},
|
||||
{
|
||||
name: "empty directory",
|
||||
input: []string{"rm", "motemen/ghqqq"},
|
||||
name: "empty directory",
|
||||
input: []string{"rm", "motemen/ghqqq"},
|
||||
setup: func(t *testing.T) {
|
||||
if err := os.MkdirAll(filepath.Join(tmpd, "github.com", "motemen", "ghqqq"), 0755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
},
|
||||
expectErr: true,
|
||||
},
|
||||
{
|
||||
name: "missing directory",
|
||||
input: []string{"rm", "motemen/missing"},
|
||||
setup: func(t *testing.T) {},
|
||||
expectErr: true,
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue