replace_map_test.go 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. Copyright 2017 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 strategy_test
  14. import (
  15. . "github.com/onsi/ginkgo"
  16. "k8s.io/kubernetes/pkg/kubectl/apply/strategy"
  17. "k8s.io/kubernetes/pkg/kubectl/cmd/util/openapi"
  18. tst "k8s.io/kubernetes/pkg/kubectl/cmd/util/openapi/testing"
  19. )
  20. var _ = Describe("Replacing fields of type map with openapi for some fields", func() {
  21. var resources openapi.Resources
  22. BeforeEach(func() {
  23. resources = tst.NewFakeResources("test_swagger.json")
  24. })
  25. Context("where a field is has been updated", func() {
  26. It("should update the field", func() {
  27. recorded := create(`
  28. apiVersion: apps/v1
  29. kind: ReplicaSet
  30. spec:
  31. template:
  32. containers:
  33. - name: container1
  34. image: image1
  35. `)
  36. local := create(`
  37. apiVersion: apps/v1
  38. kind: ReplicaSet
  39. spec:
  40. template:
  41. containers:
  42. - name: container1
  43. image: image1
  44. `)
  45. remote := create(`
  46. apiVersion: apps/v1
  47. kind: ReplicaSet
  48. spec:
  49. template:
  50. containers:
  51. - name: container1
  52. image: image1
  53. - name: container2
  54. image: image2
  55. - name: container3
  56. image: image3
  57. `)
  58. expected := create(`
  59. apiVersion: apps/v1
  60. kind: ReplicaSet
  61. spec:
  62. template:
  63. containers:
  64. - name: container1
  65. image: image1
  66. `)
  67. // Use modified swagger for ReplicaSet spec
  68. runWith(strategy.Create(strategy.Options{}), recorded, local, remote, expected, resources)
  69. })
  70. })
  71. })