Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. var Parser = require('../lib/parser'),
  2. parseListEntry = Parser.parseListEntry;
  3. var path = require('path'),
  4. assert = require('assert'),
  5. inspect = require('util').inspect;
  6. var group = path.basename(__filename, '.js') + '/';
  7. [
  8. { source: 'drwxr-xr-x 10 root root 4096 Dec 21 2012 usr',
  9. expected: {
  10. type: 'd',
  11. name: 'usr',
  12. target: undefined,
  13. sticky: false,
  14. rights: { user: 'rwx', group: 'rx', other: 'rx' },
  15. acl: false,
  16. owner: 'root',
  17. group: 'root',
  18. size: 4096,
  19. date: new Date('2012-12-21T00:00')
  20. },
  21. what: 'Normal directory'
  22. },
  23. { source: 'drwxrwxrwx 1 owner group 0 Aug 31 2012 e-books',
  24. expected: {
  25. type: 'd',
  26. name: 'e-books',
  27. target: undefined,
  28. sticky: false,
  29. rights: { user: 'rwx', group: 'rwx', other: 'rwx' },
  30. acl: false,
  31. owner: 'owner',
  32. group: 'group',
  33. size: 0,
  34. date: new Date('2012-08-31T00:00')
  35. },
  36. what: 'Normal directory #2'
  37. },
  38. { source: '-rw-rw-rw- 1 owner group 7045120 Sep 02 2012 music.mp3',
  39. expected: {
  40. type: '-',
  41. name: 'music.mp3',
  42. target: undefined,
  43. sticky: false,
  44. rights: { user: 'rw', group: 'rw', other: 'rw' },
  45. acl: false,
  46. owner: 'owner',
  47. group: 'group',
  48. size: 7045120,
  49. date: new Date('2012-09-02T00:00')
  50. },
  51. what: 'Normal file'
  52. },
  53. { source: '-rw-rw-rw-+ 1 owner group 7045120 Sep 02 2012 music.mp3',
  54. expected: {
  55. type: '-',
  56. name: 'music.mp3',
  57. target: undefined,
  58. sticky: false,
  59. rights: { user: 'rw', group: 'rw', other: 'rw' },
  60. acl: true,
  61. owner: 'owner',
  62. group: 'group',
  63. size: 7045120,
  64. date: new Date('2012-09-02T00:00')
  65. },
  66. what: 'File with ACL set'
  67. },
  68. { source: 'drwxrwxrwt 7 root root 4096 May 19 2012 tmp',
  69. expected: {
  70. type: 'd',
  71. name: 'tmp',
  72. target: undefined,
  73. sticky: true,
  74. rights: { user: 'rwx', group: 'rwx', other: 'rwx' },
  75. acl: false,
  76. owner: 'root',
  77. group: 'root',
  78. size: 4096,
  79. date: new Date('2012-05-19T00:00')
  80. },
  81. what: 'Directory with sticky bit and executable for others'
  82. },
  83. { source: 'drwxrwx--t 7 root root 4096 May 19 2012 tmp',
  84. expected: {
  85. type: 'd',
  86. name: 'tmp',
  87. target: undefined,
  88. sticky: true,
  89. rights: { user: 'rwx', group: 'rwx', other: 'x' },
  90. acl: false,
  91. owner: 'root',
  92. group: 'root',
  93. size: 4096,
  94. date: new Date('2012-05-19T00:00')
  95. },
  96. what: 'Directory with sticky bit and executable for others #2'
  97. },
  98. { source: 'drwxrwxrwT 7 root root 4096 May 19 2012 tmp',
  99. expected: {
  100. type: 'd',
  101. name: 'tmp',
  102. target: undefined,
  103. sticky: true,
  104. rights: { user: 'rwx', group: 'rwx', other: 'rw' },
  105. acl: false,
  106. owner: 'root',
  107. group: 'root',
  108. size: 4096,
  109. date: new Date('2012-05-19T00:00')
  110. },
  111. what: 'Directory with sticky bit and not executable for others'
  112. },
  113. { source: 'drwxrwx--T 7 root root 4096 May 19 2012 tmp',
  114. expected: {
  115. type: 'd',
  116. name: 'tmp',
  117. target: undefined,
  118. sticky: true,
  119. rights: { user: 'rwx', group: 'rwx', other: '' },
  120. acl: false,
  121. owner: 'root',
  122. group: 'root',
  123. size: 4096,
  124. date: new Date('2012-05-19T00:00')
  125. },
  126. what: 'Directory with sticky bit and not executable for others #2'
  127. },
  128. { source: 'total 871',
  129. expected: null,
  130. what: 'Ignored line'
  131. },
  132. ].forEach(function(v) {
  133. var result = parseListEntry(v.source),
  134. msg = '[' + group + v.what + ']: parsed output mismatch.\n'
  135. + 'Saw: ' + inspect(result) + '\n'
  136. + 'Expected: ' + inspect(v.expected);
  137. assert.deepEqual(result, v.expected, msg);
  138. });