mirror of
https://github.com/ahmetb/kubectx.git
synced 2025-05-31 11:26:00 +00:00
kubens add a short-circuit to bypass API call for tests
Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
This commit is contained in:
parent
04689f571e
commit
5348d7aa7e
@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
@ -49,6 +50,10 @@ func (op ListOp) Run(stdout, stderr io.Writer) error {
|
||||
}
|
||||
|
||||
func queryNamespaces(kc *kubeconfig.Kubeconfig) ([]string, error) {
|
||||
if os.Getenv("_MOCK_NAMESPACES") != "" {
|
||||
return []string{"ns1","ns2"}, nil
|
||||
}
|
||||
|
||||
b, err := kc.Bytes()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to convert in-memory kubeconfig to yaml")
|
||||
|
@ -1,8 +1,13 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
COMMAND="${COMMAND:-$BATS_TEST_DIRNAME/../kubens}"
|
||||
|
||||
# TODO(ahmetb) remove this after bash implementations are deleted
|
||||
export KUBECTL="$BATS_TEST_DIRNAME/../test/mock-kubectl"
|
||||
|
||||
# short-circuit namespace querying in kubens go implementation
|
||||
export _MOCK_NAMESPACES=1
|
||||
|
||||
load common
|
||||
|
||||
@test "--help should not fail" {
|
||||
|
Loading…
Reference in New Issue
Block a user