-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Abstract client rest.Config behind an interface
Too bad discovery.NewDiscoveryClientForConfigOrDie() and dynamic.NewDynamicClientPool() expects a concrete *rest.Config struct rather than a kubernetes.Interface (clientset). We can still wrap this rest.Config behind an interface. That's a first step before we can, progressively, get rid of Config (and run.go), which would make pkg/ content more like reusable packages rather than a frameworkish bunch of files.
- Loading branch information
Showing
7 changed files
with
120 additions
and
40 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,51 @@ | ||
package cmd | ||
|
||
import ( | ||
"bytes" | ||
"testing" | ||
|
||
"k8s.io/client-go/rest" | ||
) | ||
|
||
type mockClient struct{} | ||
|
||
func (m *mockClient) GetRestConfig() *rest.Config { | ||
return &rest.Config{} | ||
} | ||
|
||
func TestRootCmd(t *testing.T) { | ||
restcfg = new(mockClient) | ||
RootCmd.SetOutput(new(bytes.Buffer)) | ||
RootCmd.SetArgs([]string{ | ||
"--config", | ||
"/dev/null", | ||
"--kube-config", | ||
"/dev/null", | ||
"--dry-run", | ||
"--dump-only", | ||
"--api-server", | ||
"http://192.0.2.1", // RFC 5737 reserved/unroutable | ||
"--log-level", | ||
"warning", | ||
"--log-output", | ||
"test", | ||
"--healthcheck-port", | ||
"0", | ||
"--filter", | ||
"foo=bar,spam=egg", | ||
"--resync-interval", | ||
"1", | ||
}) | ||
|
||
if err := Execute(); err != nil { | ||
t.Errorf("version subcommand shouldn't fail: %+v", err) | ||
} | ||
} | ||
|
||
func TestVersionCmd(t *testing.T) { | ||
RootCmd.SetOutput(new(bytes.Buffer)) | ||
RootCmd.SetArgs([]string{"version"}) | ||
if err := RootCmd.Execute(); err != nil { | ||
t.Errorf("version subcommand shouldn't fail: %+v", err) | ||
} | ||
} |
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
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
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