Commit 43239e91
43239e91a76eMerged
Sviatoslav Dumchenko <[email protected]> ยท 3 years ago ยท 1 file ยท ~1 modified
Description
chore(tests): test that hooks are actually run
Details
- Commit
- 43239e91a76e
- Parent
- 5a1fa107155b
pkg/action/build_internal_test.gomodifiedView file
@@ -1,6 +1,7 @@
11
package action22
33
import (4+
"bytes"45
"context"56
"path/filepath"67
"strings"@@ -9,6 +10,7 @@
910
"github.com/helmwave/helmwave/pkg/plan"1011
"github.com/helmwave/helmwave/pkg/repo"1112
"github.com/helmwave/helmwave/tests"13+
log "github.com/sirupsen/logrus"1214
"github.com/stretchr/testify/suite"1315
"github.com/urfave/cli/v2"1416
)@@ -210,6 +212,39 @@
210212
ts.Require().DirExists(filepath.Join(s.plandir, plan.Manifest))211213
}212214
215+
func (ts *NonParallelBuildTestSuite) TestLifecycle() {216+
tmpDir := ts.T().TempDir()217+
y := &Yml{218+
tpl: filepath.Join(tests.Root, "13_helmwave.yml"),219+
file: filepath.Join(tmpDir, "13_helmwave.yml"),220+
templater: "sprig",221+
}222+
223+
s := &Build{224+
plandir: tmpDir,225+
tags: cli.StringSlice{},226+
options: plan.BuildOptions{227+
MatchAll: true,228+
},229+
autoYml: true,230+
yml: y,231+
}232+
233+
var buf bytes.Buffer234+
oldOut := log.StandardLogger().Out235+
log.StandardLogger().SetOutput(&buf)236+
defer log.StandardLogger().SetOutput(oldOut)237+
238+
ts.Require().NoError(s.Run(context.Background()))239+
ts.Require().DirExists(filepath.Join(s.plandir, plan.Manifest))240+
241+
output := buf.String()242+
ts.Require().Contains(output, "running pre_build script for nginx")243+
ts.Require().Contains(output, "run global pre_build script")244+
ts.Require().Contains(output, "running post_build script for nginx")245+
ts.Require().Contains(output, "run global post_build script")246+
}247+
213248
//nolintlint:paralleltest // can't parallel because of setenv and uses helm repository.yaml flock214249
func TestNonParallelNonParallelBuildTestSuite(t *testing.T) {215250
// t.Parallel()