airshipctl/pkg/k8s/client/client_test.go
Ian Howell 5eec83e05f Fix a failure when running unit tests locally
This change fixes an issue in pkg/k8s/client.TestNewClient in which the
unit test was using the developer's real airship config file. This was,
in some cases, causing unit tests to fail when run locally.

Change-Id: Ic8911b9e72d3e76f0219472ea0a9de5b3b255c3b
2020-03-13 14:43:43 -05:00

41 lines
918 B
Go

package client_test
import (
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"opendev.org/airship/airshipctl/pkg/environment"
"opendev.org/airship/airshipctl/pkg/k8s/client"
"opendev.org/airship/airshipctl/testutil"
)
const (
kubeconfigPath = "testdata/kubeconfig.yaml"
airshipConfigDir = "testdata"
)
func TestNewClient(t *testing.T) {
settings := &environment.AirshipCTLSettings{}
conf, cleanup := testutil.InitConfig(t)
defer cleanup(t)
settings.SetConfig(conf)
akp, err := filepath.Abs(kubeconfigPath)
require.NoError(t, err)
adir, err := filepath.Abs(airshipConfigDir)
require.NoError(t, err)
settings.SetAirshipConfigPath(adir)
settings.SetKubeConfigPath(akp)
client, err := client.NewClient(settings)
assert.NoError(t, err)
assert.NotNil(t, client)
assert.NotNil(t, client.ClientSet())
assert.NotNil(t, client.Kubectl())
}