Skip to content
Snippets Groups Projects
cmd_test.go 898 B
Newer Older
Florent Aide's avatar
Florent Aide committed
package runner

import (
	"fmt"
	"testing"

	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/require"
	"orus.io/cloudcrane/beaver/testutils"
Florent Aide's avatar
Florent Aide committed
)

func TestRunCMD(t *testing.T) {
	err, stdout, stderr := RunCMD("echo", "p00f")
	require.NoError(t, err)
	for _, out := range stdout {
		assert.Equal(t, "p00f", out)
		fmt.Println(out)
	}
	for _, errMsg := range stderr {
		fmt.Println(errMsg)
	}
}

func TestCmdConfig(t *testing.T) {
	tl := testutils.NewTestLogger(t)
	testNS := "ns1"
	c, err := NewCmdConfig(tl.Logger(), "fixtures/", testNS)
	require.NoError(t, err)

	// TODO: make sure this is the expected values including the leading | ...
	assert.Equal(t, []string{
		"|\n  config:\n    datasource:\n      password: <path:cnpp.k8s.cloudcrane.io/data/ns1/postgres#password>\n    role: 'admin'\n  fullnameoverride: pg-exporter-ns1\n"},
		c.Spec.Charts.Helm["postgres"].Values,
	)
}