Arch Linux helpers and parsers
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

206 lines
4.0 KiB

3 years ago
3 years ago
  1. package archlinux
  2. import (
  3. "bytes"
  4. "io"
  5. "io/ioutil"
  6. "os"
  7. "testing"
  8. )
  9. func TestReadPackageDesc(t *testing.T) {
  10. pkg, err := ReadPackageDesc(bytes.NewBufferString(testReadPackageDesc))
  11. if err != nil {
  12. t.Fatal(err)
  13. }
  14. // TODO(maze): checks
  15. _ = pkg
  16. }
  17. var (
  18. testReadPackageDesc = `%FILENAME%
  19. perl-5.26.0-4-x86_64.pkg.tar.xz
  20. %NAME%
  21. perl
  22. %VERSION%
  23. 5.26.0-4
  24. %DESC%
  25. A highly capable, feature-rich programming language
  26. %GROUPS%
  27. base
  28. %CSIZE%
  29. 14343632
  30. %ISIZE%
  31. 54492160
  32. %MD5SUM%
  33. 08a8b1fcab42ec43fdf07c4a5b1b2f50
  34. %SHA256SUM%
  35. ab958e0796650557a227f7eff56924ea8d03160803f8d061717b6013ee0045c1
  36. %PGPSIG%
  37. iQEzBAABCAAdFiEEhs/8qRjPOvRxR1iAUeixSKmZnDQFAlmew3MACgkQUeixSKmZnDRRhwf/Q0Ve+pIQAxknR0v3p2FyWgfuanwYCpWhIZgTCKGCmCntayBKZ0U9v41Mac7PJ11AJvntNWJ9vhmR3dqpj6AOw6lXa4AGXUCHOmo21FMYEPltcp27zRCk/7FHFHwxDd+8y0cU8x4l7QVmTq4odMjAQiimMEcxY/jXsoUX084SzOQ02ix2DA67spFLAD7BC9z6tmdH9ABXaRA8QL51uQxGaQ+fxc8FKXFjOhbNyPcjOZasiwvrLboB/nQRfygf0baBSzzbM/hOnHVgqc3WfAqE1y4Qve8cE1L+2hhXXHaFCj9/v6vI1JZGQlMYisbhYMuK0n4kM4RbX7N6I78IHuRuyg==
  38. %URL%
  39. http://www.perl.org
  40. %LICENSE%
  41. GPL
  42. PerlArtistic
  43. %ARCH%
  44. x86_64
  45. %BUILDDATE%
  46. 1503575763
  47. %PACKAGER%
  48. Evangelos Foutras <evangelos@foutrelis.com>
  49. %PROVIDES%
  50. perl-archive-tar=2.24
  51. perl-attribute-handlers=0.99
  52. perl-autodie=2.29
  53. perl-autoloader=5.74
  54. perl-autouse=1.11
  55. perl-b-debug=1.24
  56. perl-base=2.25
  57. perl-bignum=0.47
  58. perl-carp=1.42
  59. perl-compress-raw-bzip2=2.074
  60. perl-compress-raw-zlib=2.074
  61. perl-config-perl-v=0.28
  62. perl-constant=1.33
  63. perl-cpan-meta-requirements=2.140
  64. perl-cpan-meta-yaml=0.018
  65. perl-cpan-meta=2.150010
  66. perl-cpan=2.18
  67. perl-data-dumper=2.167
  68. perl-db_file=1.840
  69. perl-devel-ppport=3.35
  70. perl-devel-selfstubber=1.06
  71. perl-digest-md5=2.55
  72. perl-digest-sha=5.96
  73. perl-digest=1.17_01
  74. perl-dumpvalue=1.18
  75. perl-encode=2.88
  76. perl-encoding-warnings=0.13
  77. perl-env=1.04
  78. perl-experimental=0.016
  79. perl-exporter=5.72
  80. perl-extutils-cbuilder=0.280225
  81. perl-extutils-constant=0.23
  82. perl-extutils-install=2.04
  83. perl-extutils-makemaker=7.24
  84. perl-extutils-manifest=1.70
  85. perl-extutils-parsexs=3.34
  86. perl-file-fetch=0.52
  87. perl-file-path=2.12_01
  88. perl-file-temp=0.2304
  89. perl-filter-simple=0.93
  90. perl-filter-util-call=1.55
  91. perl-getopt-long=2.49
  92. perl-http-tiny=0.070
  93. perl-i18n-collate=1.02
  94. perl-i18n-langtags=0.42
  95. perl-if=0.0606
  96. perl-io-compress=2.074
  97. perl-io-socket-ip=0.38
  98. perl-io-zlib=1.10
  99. perl-io=1.38
  100. perl-ipc-cmd=0.96
  101. perl-ipc-sysv=2.07
  102. perl-json-pp=2.27400_02
  103. perl-lib=0.64
  104. perl-libnet=3.10
  105. perl-locale-codes=3.42
  106. perl-locale-maketext-simple=0.21_01
  107. perl-locale-maketext=1.28
  108. perl-math-bigint-fastcalc=0.5005
  109. perl-math-bigint=1.999806
  110. perl-math-bigrat=0.2611
  111. perl-math-complex=1.5901
  112. perl-memoize=1.03_01
  113. perl-mime-base64=3.15
  114. perl-module-corelist=5.20170530
  115. perl-module-load-conditional=0.68
  116. perl-module-load=0.32
  117. perl-module-loaded=0.08
  118. perl-module-metadata=1.000033
  119. perl-net-ping=2.55
  120. perl-params-check=0.38
  121. perl-parent=0.236
  122. perl-pathtools=3.67
  123. perl-perl-ostype=1.010
  124. perl-perlfaq=5.021011
  125. perl-perlio-via-quotedprint=0.08
  126. perl-pod-checker=1.73
  127. perl-pod-escapes=1.07
  128. perl-pod-parser=1.63
  129. perl-pod-perldoc=3.28
  130. perl-pod-simple=3.35
  131. perl-pod-usage=1.69
  132. perl-podlators=5.006
  133. perl-safe=2.40
  134. perl-scalar-list-utils=1.46_02
  135. perl-search-dict=1.07
  136. perl-selfloader=1.23
  137. perl-socket=2.020_03
  138. perl-storable=2.62
  139. perl-sys-syslog=0.35
  140. perl-term-ansicolor=4.06
  141. perl-term-cap=1.17
  142. perl-term-complete=1.403
  143. perl-term-readline=1.16
  144. perl-test-harness=3.38
  145. perl-test-simple=1.302073
  146. perl-test=1.30
  147. perl-text-abbrev=1.02
  148. perl-text-balanced=2.03
  149. perl-text-parsewords=3.30
  150. perl-text-tabs=2013.0523
  151. perl-thread-queue=3.12
  152. perl-thread-semaphore=2.13
  153. perl-threads-shared=1.56
  154. perl-threads=2.15
  155. perl-tie-file=1.02
  156. perl-tie-refhash=1.39
  157. perl-time-hires=1.9741
  158. perl-time-local=1.25
  159. perl-time-piece=1.31
  160. perl-unicode-collate=1.19
  161. perl-unicode-normalize=1.25
  162. perl-version=0.9917
  163. perl-xsloader=0.27
  164. %DEPENDS%
  165. gdbm
  166. db
  167. glibc
  168. `
  169. )
  170. func TestWritePackageDesc(t *testing.T) {
  171. var w io.Writer
  172. if os.Getenv("TEST_DEBUG_WRITER") != "" {
  173. w = os.Stdout
  174. } else {
  175. w = ioutil.Discard
  176. }
  177. n, err := testWritePackageInfo.WritePackageDesc(w)
  178. if err != nil {
  179. t.Fatal(err)
  180. }
  181. if n == 0 {
  182. t.Fatal(`expected >0 bytes to be written`)
  183. }
  184. t.Log(n, "bytes written")
  185. }