This repository has been archived by the owner on Jan 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 489
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #403 from wwitzel3/issue-150
fix issue with kubeconfig not being fetched correctly from envvar
- Loading branch information
Showing
2 changed files
with
41 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
Copyright (c) 2019 the Octant contributors. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package commands | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func Test_bindViper_KUBECONFIG(t *testing.T) { | ||
cmd := &cobra.Command{} | ||
|
||
expected := "/testdata/kubeconfig.yml" | ||
os.Setenv("KUBECONFIG", expected) | ||
defer os.Unsetenv("KUBECONFIG") | ||
|
||
// Before bindViper | ||
actual := viper.GetString("kubeconfig") | ||
assert.Equal(t, "", actual) | ||
|
||
err := bindViper(cmd) | ||
require.NoError(t, err) | ||
|
||
// After bindViper | ||
actual = viper.GetString("kubeconfig") | ||
assert.Equal(t, expected, actual) | ||
} |