step3_controller_test.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. var Ember = require('ember');
  20. require('models/host');
  21. require('controllers/wizard/stack_upgrade/step3_controller');
  22. describe('App.StackUpgradeStep3Controller', function() {
  23. var stackUpgradeStep3Controller = App.StackUpgradeStep3Controller.create();
  24. beforeEach(function() {
  25. sinon.stub(App.router, 'get', function(k) {
  26. if ('stackUpgradeController' === k) return Em.Object.create({
  27. save: Em.K
  28. })
  29. if ('stackUpgradeController.save' === k) return Em.K;
  30. return Em.get(App.router, k);
  31. });
  32. });
  33. afterEach(function() {
  34. App.router.get.restore();
  35. });
  36. describe('#runUpgradeErrorCallback', function() {
  37. var processes = [
  38. Ember.Object.create({
  39. status: '',
  40. isRetry: false,
  41. name: 'UPGRADE_SERVICES'
  42. })
  43. ];
  44. stackUpgradeStep3Controller.set('processes', processes);
  45. stackUpgradeStep3Controller.set('content', {cluster: {}, controllerName:'stackUpgradeController'});
  46. it('check process condition', function() {
  47. sinon.stub(App, 'get', function(k) {
  48. if ('testMode' === k) return true;
  49. return Em.get(App, k);
  50. });
  51. stackUpgradeStep3Controller.runUpgradeErrorCallback();
  52. expect(stackUpgradeStep3Controller.get('processes').findProperty('name', 'UPGRADE_SERVICES').get('status')).to.equal('FAILED');
  53. expect(stackUpgradeStep3Controller.get('processes').findProperty('name', 'UPGRADE_SERVICES').get('isRetry')).to.equal(true);
  54. expect(stackUpgradeStep3Controller.get('submitButton')).to.equal(false);
  55. App.get.restore();
  56. });
  57. });
  58. });