github.com/olli-ai/jx/v2@v2.0.400-0.20210921045218-14731b4dd448/pkg/cmd/step/step_next_version_test.go (about)

     1  // +build unit
     2  
     3  package step_test
     4  
     5  import (
     6  	"testing"
     7  
     8  	step2 "github.com/olli-ai/jx/v2/pkg/cmd/opts/step"
     9  	"github.com/olli-ai/jx/v2/pkg/cmd/step"
    10  
    11  	"github.com/olli-ai/jx/v2/pkg/cmd/opts"
    12  	"github.com/stretchr/testify/assert"
    13  )
    14  
    15  func TestMakefile(t *testing.T) {
    16  	t.Parallel()
    17  	o := step.StepNextVersionOptions{
    18  		StepOptions: step2.StepOptions{
    19  			CommonOptions: &opts.CommonOptions{},
    20  		},
    21  		Dir:      "test_data/next_version/make",
    22  		Filename: "Makefile",
    23  	}
    24  
    25  	v, err := o.GetVersion()
    26  
    27  	assert.NoError(t, err)
    28  
    29  	assert.Equal(t, "1.2.0-SNAPSHOT", v, "error with GetVersion for a Makefile")
    30  }
    31  
    32  func TestPomXML(t *testing.T) {
    33  	t.Parallel()
    34  	o := step.StepNextVersionOptions{
    35  		StepOptions: step2.StepOptions{
    36  			CommonOptions: &opts.CommonOptions{},
    37  		},
    38  		Dir:      "test_data/next_version/java",
    39  		Filename: "pom.xml",
    40  	}
    41  
    42  	v, err := o.GetVersion()
    43  
    44  	assert.NoError(t, err)
    45  
    46  	assert.Equal(t, "1.0-SNAPSHOT", v, "error with GetVersion for a pom.xml")
    47  }
    48  
    49  func TestChart(t *testing.T) {
    50  	t.Parallel()
    51  	o := step.StepNextVersionOptions{
    52  		StepOptions: step2.StepOptions{
    53  			CommonOptions: &opts.CommonOptions{},
    54  		},
    55  		Dir:      "test_data/next_version/helm",
    56  		Filename: "Chart.yaml",
    57  	}
    58  
    59  	v, err := o.GetVersion()
    60  
    61  	assert.NoError(t, err)
    62  
    63  	assert.Equal(t, "0.0.1-SNAPSHOT", v, "error with GetVersion for a Chart.yaml")
    64  }