forked from gobuffalo/genny
-
Notifications
You must be signed in to change notification settings - Fork 0
/
force_test.go
45 lines (35 loc) · 821 Bytes
/
force_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package genny
import (
"context"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/require"
)
func Test_Force_Exists(t *testing.T) {
r := require.New(t)
dir, err := ioutil.TempDir("", "test")
r.NoError(err)
f, err := os.Create(filepath.Join(dir, "foo.txt"))
r.NoError(err)
fmt.Fprint(f, "asd")
f.Close()
run := DryRunner(context.Background())
run.WithRun(Force(dir, false))
r.Error(run.Run())
run = DryRunner(context.Background())
run.WithRun(Force(dir, true))
r.NoError(run.Run())
}
func Test_Force_Doesnt_Exists(t *testing.T) {
r := require.New(t)
dir := "i don't exist"
run := DryRunner(context.Background())
run.WithRun(Force(dir, false))
r.NoError(run.Run())
run = DryRunner(context.Background())
run.WithRun(Force(dir, true))
r.NoError(run.Run())
}