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

     1  //go:build integration
     2  
     3  package action
     4  
     5  import (
     6  	"context"
     7  	"os"
     8  	"path/filepath"
     9  	"testing"
    10  
    11  	"github.com/databus23/helm-diff/v3/diff"
    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 DiffLiveTestSuite struct {
    19  	suite.Suite
    20  
    21  	ctx context.Context
    22  }
    23  
    24  //nolint:paralleltest // uses helm repository.yaml flock
    25  func TestDiffLiveTestSuite(t *testing.T) {
    26  	// t.Parallel()
    27  	suite.Run(t, new(DiffLiveTestSuite))
    28  }
    29  
    30  func (ts *DiffLiveTestSuite) SetupTest() {
    31  	ts.ctx = tests.GetContext(ts.T())
    32  }
    33  
    34  func (ts *DiffLiveTestSuite) TestCmd() {
    35  	s := &DiffLive{diff: &Diff{Options: &diff.Options{}}}
    36  	cmd := s.Cmd()
    37  
    38  	ts.Require().NotNil(cmd)
    39  	ts.Require().NotEmpty(cmd.Name)
    40  }
    41  
    42  func (ts *DiffLiveTestSuite) TestRun() {
    43  	tmpDir := ts.T().TempDir()
    44  	y := &Yml{
    45  		tpl:       filepath.Join(tests.Root, "02_helmwave.yml"),
    46  		file:      filepath.Join(tests.Root, "02_helmwave.yml"),
    47  		templater: template.TemplaterSprig,
    48  	}
    49  
    50  	s := &Build{
    51  		plandir:  tmpDir,
    52  		tags:     cli.StringSlice{},
    53  		yml:      y,
    54  		diff:     &Diff{Options: &diff.Options{}},
    55  		diffMode: DiffModeLive,
    56  	}
    57  
    58  	d := DiffLive{diff: s.diff, plandir: s.plandir}
    59  
    60  	ts.Require().ErrorIs(d.Run(ts.ctx), os.ErrNotExist)
    61  	ts.Require().NoError(s.Run(ts.ctx))
    62  	ts.Require().NoError(d.Run(ts.ctx))
    63  }