Unittest for #9762

Started looking at refactoring of the kubectl Factory, which
caused me to experience all 5 stages of grief. There are some options
for improving, but it probably warrants a proposal with some discussion/
feedback. In the meantime this tests `NegotiateVersion` in isolation.
This commit is contained in:
Jeff Lowdermilk
2015-06-16 20:04:51 -07:00
parent 1dd18673ec
commit 57a6355807
3 changed files with 100 additions and 12 deletions

View File

@@ -36,6 +36,7 @@ type clientCache struct {
clients map[string]*client.Client
configs map[string]*client.Config
defaultConfig *client.Config
defaultClient *client.Client
matchVersion bool
}
@@ -48,7 +49,7 @@ func (c *clientCache) ClientConfigForVersion(version string) (*client.Config, er
}
c.defaultConfig = config
if c.matchVersion {
if err := client.MatchesServerVersion(config); err != nil {
if err := client.MatchesServerVersion(c.defaultClient, config); err != nil {
return nil, err
}
}
@@ -58,7 +59,7 @@ func (c *clientCache) ClientConfigForVersion(version string) (*client.Config, er
}
// TODO: have a better config copy method
config := *c.defaultConfig
negotiatedVersion, err := client.NegotiateVersion(&config, version)
negotiatedVersion, err := client.NegotiateVersion(c.defaultClient, &config, version)
if err != nil {
return nil, err
}