progress_controller_test.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. var App = require('app');
  19. require('controllers/main/admin/highAvailability_controller');
  20. require('models/host_component');
  21. require('models/host');
  22. require('utils/ajax/ajax');
  23. describe('App.HighAvailabilityProgressPageController', function () {
  24. var controller = App.HighAvailabilityProgressPageController.create();
  25. describe('#reconfigureSites()', function () {
  26. var tests = [
  27. {
  28. siteNames: ["site1", "site2"],
  29. data: {
  30. items: [
  31. {
  32. type: "site1",
  33. properties: {
  34. site1_property1: "site1_property1_value",
  35. site1_property2: "site1_property2_value"
  36. },
  37. properties_attributes: {
  38. final: {
  39. site1_property1: "true"
  40. }
  41. }
  42. },
  43. {
  44. type: "site2",
  45. properties: {
  46. site2_property1: "site2_property1_value",
  47. site2_property2: "site2_property2_value"
  48. }
  49. },
  50. {
  51. type: "site3",
  52. properties: {
  53. site3_property: "site3_property_value"
  54. }
  55. }
  56. ]
  57. },
  58. note: 'note1',
  59. result: [
  60. {
  61. type: "site1",
  62. tag: "version1",
  63. properties: {
  64. site1_property1: "site1_property1_value",
  65. site1_property2: "site1_property2_value"
  66. },
  67. service_config_version_note: 'note1',
  68. properties_attributes: {
  69. final: {
  70. site1_property1: "true"
  71. }
  72. }
  73. },
  74. {
  75. type: "site2",
  76. tag: "version1",
  77. properties: {
  78. site2_property1: "site2_property1_value",
  79. site2_property2: "site2_property2_value"
  80. },
  81. service_config_version_note: 'note1'
  82. }
  83. ]
  84. },
  85. {
  86. siteNames: ["site1"],
  87. data: {
  88. items: [
  89. {
  90. type: "site1",
  91. properties: {
  92. site1_property1: "site1_property1_value",
  93. site1_property2: "site1_property2_value"
  94. },
  95. properties_attributes: {
  96. final: {
  97. site1_property1: "true"
  98. }
  99. }
  100. }
  101. ]
  102. },
  103. note: 'note2',
  104. result: [
  105. {
  106. type: "site1",
  107. tag: "version1",
  108. properties: {
  109. site1_property1: "site1_property1_value",
  110. site1_property2: "site1_property2_value"
  111. },
  112. service_config_version_note: 'note2',
  113. properties_attributes: {
  114. final: {
  115. site1_property1: "true"
  116. }
  117. }
  118. }
  119. ]
  120. }];
  121. beforeEach(function() {
  122. App.set('testMode', true);
  123. });
  124. afterEach(function() {
  125. App.set('testMode', false);
  126. });
  127. it("reconfigures configs after HA", function() {
  128. tests.forEach(function(t) {
  129. controller.set('content', t.content);
  130. expect(controller.reconfigureSites(t.siteNames, t.data, t.note)).to.eql(t.result);
  131. });
  132. });
  133. });
  134. });