github.com/jenkins-x/jx-api@v0.0.24/pkg/config/install_applications_test.go (about)

     1  package config_test
     2  
     3  import (
     4  	"path"
     5  	"strings"
     6  	"testing"
     7  
     8  	"github.com/jenkins-x/jx-api/pkg/config"
     9  
    10  	"github.com/stretchr/testify/assert"
    11  )
    12  
    13  func TestJenkinsXAppsUnmarshalling(t *testing.T) {
    14  	apps, err := config.LoadApplicationsConfig(path.Join("test_data"))
    15  	assert.NoError(t, err)
    16  
    17  	// assert marshalling of a jx-apps.yaml
    18  	assert.Equal(t, 4, len(apps.Applications))
    19  	assert.Equal(t, "cert-manager", apps.Applications[3].Namespace)
    20  }
    21  
    22  func TestBadPhase(t *testing.T) {
    23  	_, err := config.LoadApplicationsConfig(path.Join("test_data", "jx-apps-phase-bad"))
    24  	assert.Error(t, err)
    25  	assert.True(t, strings.HasPrefix(err.Error(), "failed to validate YAML file"))
    26  }
    27  
    28  func TestGoodPhase(t *testing.T) {
    29  	apps, err := config.LoadApplicationsConfig(path.Join("test_data", "jx-apps-phase-good"))
    30  	assert.NoError(t, err)
    31  	assert.Equal(t, "velero", apps.Applications[0].Name)
    32  	assert.Equal(t, config.PhaseSystem, apps.Applications[0].Phase)
    33  	assert.Equal(t, "external-dns", apps.Applications[1].Name)
    34  	assert.Equal(t, config.PhaseApps, apps.Applications[1].Phase)
    35  }