github.com/helmwave/helmwave@v0.36.4-0.20240509190856-b35563eba4c6/pkg/action/up_internal_test.go (about)

     1  //go:build integration
     2  
     3  package action
     4  
     5  import (
     6  	"context"
     7  	"path/filepath"
     8  	"strings"
     9  	"testing"
    10  
    11  	"github.com/helmwave/helmwave/pkg/kubedog"
    12  	"github.com/helmwave/helmwave/pkg/template"
    13  	"github.com/helmwave/helmwave/tests"
    14  	"github.com/stretchr/testify/suite"
    15  	"github.com/urfave/cli/v2"
    16  )
    17  
    18  type UpTestSuite struct {
    19  	suite.Suite
    20  
    21  	ctx context.Context
    22  }
    23  
    24  //nolint:paralleltest // can't parallel because of setenv
    25  func TestUpTestSuite(t *testing.T) {
    26  	// t.Parallel()
    27  	suite.Run(t, new(UpTestSuite))
    28  }
    29  
    30  func (ts *UpTestSuite) SetupTest() {
    31  	ts.ctx = tests.GetContext(ts.T())
    32  }
    33  
    34  func (ts *UpTestSuite) TestCmd() {
    35  	s := &Up{}
    36  	cmd := s.Cmd()
    37  
    38  	ts.Require().NotNil(cmd)
    39  	ts.Require().NotEmpty(cmd.Name)
    40  }
    41  
    42  func (ts *UpTestSuite) TestAutoBuild() {
    43  	tmpDir := ts.T().TempDir()
    44  	y := &Yml{
    45  		tpl:       filepath.Join(tests.Root, "01_helmwave.yml.tpl"),
    46  		file:      filepath.Join(tmpDir, "02_helmwave.yml"),
    47  		templater: template.TemplaterSprig,
    48  	}
    49  
    50  	u := &Up{
    51  		build: &Build{
    52  			plandir: tmpDir,
    53  			tags:    cli.StringSlice{},
    54  			autoYml: true,
    55  			yml:     y,
    56  		},
    57  		dog:       &kubedog.Config{},
    58  		autoBuild: true,
    59  	}
    60  
    61  	value := strings.ToLower(strings.ReplaceAll(ts.T().Name(), "/", ""))
    62  	ts.T().Setenv("NAMESPACE", value)
    63  
    64  	ts.Require().NoError(u.Run(ts.ctx))
    65  }