github.com/verrazzano/verrazzano@v1.7.0/pkg/helm/chart_test.go (about)

     1  // Copyright (c) 2021, 2022, Oracle and/or its affiliates.
     2  // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
     3  
     4  package helm
     5  
     6  import (
     7  	"github.com/stretchr/testify/assert"
     8  	"testing"
     9  )
    10  
    11  // TestGetChart tests getting the contents of Chart.yaml
    12  // GIVEN a chart directory
    13  //
    14  //	WHEN I call GetChart
    15  //	THEN the correct chart data is returned
    16  func TestGetChart(t *testing.T) {
    17  	assert := assert.New(t)
    18  	chart, err := GetChartInfo("./testdata")
    19  	assert.NoError(err, "GetChartInfo returned an error")
    20  	assert.Equal(chart.APIVersion, "v1", "incorrect API version")
    21  	assert.Equal(chart.Version, "0.8.0", "incorrect chart version")
    22  	assert.Equal(chart.AppVersion, "0.8.0-app", "incorrect chart app version")
    23  	assert.Equal(chart.Description, "Test Helm Chart", "incorrect chart description")
    24  	assert.Equal(chart.Name, "testChart", "incorrect chart name")
    25  }
    26  
    27  // TestGetChartNoFile tests getting the error handling of getting a chart when the file doesn't exist
    28  // GIVEN a chart directory with no chart file
    29  //
    30  //	WHEN I call GetChart
    31  //	THEN an error is returned
    32  func TestGetChartNoFile(t *testing.T) {
    33  	assert := assert.New(t)
    34  	_, err := GetChartInfo("./")
    35  	assert.Error(err, "GetChartInfo should have returned an error")
    36  }