deprecated_test.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. Copyright 2018 The Kubernetes Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package options
  14. import (
  15. "testing"
  16. )
  17. func TestValidateDeprecatedKubeSchedulerConfiguration(t *testing.T) {
  18. scenarios := map[string]struct {
  19. expectedToFail bool
  20. config *DeprecatedOptions
  21. }{
  22. "good": {
  23. expectedToFail: false,
  24. config: &DeprecatedOptions{
  25. PolicyConfigFile: "/some/file",
  26. UseLegacyPolicyConfig: true,
  27. AlgorithmProvider: "",
  28. },
  29. },
  30. "bad-policy-config-file-null": {
  31. expectedToFail: true,
  32. config: &DeprecatedOptions{
  33. PolicyConfigFile: "",
  34. UseLegacyPolicyConfig: true,
  35. AlgorithmProvider: "",
  36. },
  37. },
  38. }
  39. for name, scenario := range scenarios {
  40. errs := scenario.config.Validate()
  41. if len(errs) == 0 && scenario.expectedToFail {
  42. t.Errorf("Unexpected success for scenario: %s", name)
  43. }
  44. if len(errs) > 0 && !scenario.expectedToFail {
  45. t.Errorf("Unexpected failure for scenario: %s - %+v", name, errs)
  46. }
  47. }
  48. }