Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

Commit

Permalink
Fix skip build deps on cleanup (#1675)
Browse files Browse the repository at this point in the history
* Fixed skip build deps option so that  is not called if dependencies are not built

* Forgot debug print
  • Loading branch information
jani123 authored and markbates committed Jun 3, 2019
1 parent 01ea079 commit 4c0a86b
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 1 deletion.
2 changes: 1 addition & 1 deletion genny/build/cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func Cleanup(opts *Options) genny.RunFn {
return err
}
}
if envy.Mods() {
if envy.Mods() && opts.WithBuildDeps {
if err := r.Exec(exec.Command(genny.GoBin(), "mod", "tidy")); err != nil {
return err
}
Expand Down
62 changes: 62 additions & 0 deletions genny/build/cleanup_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package build

import (
"sync"
"testing"

"github.com/gobuffalo/envy"
"github.com/gobuffalo/genny/gentest"
"github.com/gobuffalo/meta"
"github.com/stretchr/testify/require"
)

func Test_WithDeps(t *testing.T) {
r := require.New(t)
envy.Set(envy.GO111MODULE, "on")

run := gentest.NewRunner()

opts := &Options{
WithAssets: false,
WithBuildDeps: true,
Environment: "bar",
App: meta.New("."),
}

emptyMap := sync.Map{}
opts.rollback = &emptyMap

f := Cleanup(opts)
f(run)

results := run.Results()

cmds := []string{"go mod tidy"}
for i, c := range results.Commands {
eq(r, cmds[i], c)
}
}

func Test_WithoutDeps(t *testing.T) {
r := require.New(t)
envy.Set(envy.GO111MODULE, "on")

run := gentest.NewRunner()

opts := &Options{
WithAssets: false,
WithBuildDeps: false,
Environment: "bar",
App: meta.New("."),
}

emptyMap := sync.Map{}
opts.rollback = &emptyMap

f := Cleanup(opts)
f(run)

results := run.Results()

r.Len(results.Commands, 0)
}

0 comments on commit 4c0a86b

Please sign in to comment.