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

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