yarn-container-log-test.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. import { moduleFor, test } from 'ember-qunit';
  19. import Constants from 'yarn-ui/constants';
  20. moduleFor('adapter:yarn-container-log', 'Unit | Adapter | ContainerLog', {
  21. });
  22. test('Basic creation', function(assert) {
  23. let adapter = this.subject();
  24. assert.ok(adapter);
  25. assert.ok(adapter.urlForFindRecord);
  26. assert.ok(adapter.ajax);
  27. assert.ok(adapter.headers);
  28. assert.ok(adapter.host);
  29. assert.ok(adapter.namespace);
  30. assert.equal(adapter.headers.Accept, "text/plain");
  31. assert.equal(adapter.namespace, "ws/v1/node");
  32. });
  33. test('urlForFindRecord test', function(assert) {
  34. let adapter = this.subject();
  35. let host = adapter.host;
  36. assert.equal(adapter.urlForFindRecord("localhost:8042" +
  37. Constants.PARAM_SEPARATOR + "container_e27_11111111111_0001_01_000001" +
  38. Constants.PARAM_SEPARATOR + "syslog"),
  39. host + "localhost:8042/ws/v1/node/containerlogs/" +
  40. "container_e27_11111111111_0001_01_000001/syslog");
  41. });
  42. test('ajaxOptions test', function(assert) {
  43. let adapter = this.subject();
  44. var hash = adapter.ajaxOptions('/containerlogs', 'type', {});
  45. assert.equal(hash.dataType, 'text');
  46. });
  47. test('findRecord test', function(assert) {
  48. let adapter = this.subject(),
  49. testModel = { modelName: "testModel" },
  50. testStore = {},
  51. testSnapshot = {};
  52. let host = adapter.host;
  53. let testId = "localhost:8042" + Constants.PARAM_SEPARATOR +
  54. "container_e27_11111111111_0001_01_000001" + Constants.PARAM_SEPARATOR +
  55. "syslog";
  56. assert.expect(2);
  57. adapter.ajax = function (url, method) {
  58. assert.equal(url, host + "localhost:8042/ws/v1/node/containerlogs/" +
  59. "container_e27_11111111111_0001_01_000001/syslog");
  60. assert.equal(method, 'GET');
  61. };
  62. adapter.findRecord(testStore, testModel, testId, testSnapshot);
  63. });