Remove n0emis as direct maintainer (#365023)
[NixPkgs.git] / pkgs / applications / office / libreoffice / darwin / update-test.nix
blob0d9119eaeae7488eab9246f5b7d2c7f82b889cad
1 # run the tests with nixt <absolutePath to parent dir> -v
4   pkgs ? import <nixpkgs> { },
5   nixt,
6 }:
7 let
8   inherit (import ./update-utils.nix { inherit (pkgs) lib; })
9     extractLatestVersionFromHtml
10     extractSha256FromHtml
11     getLatestStableVersion
12     ;
14 nixt.mkSuite "LibreOffice Updater" {
15   "should extract latest stable version from html" =
16     let
17       latestVersionHtmlMock = ''
18         <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
19         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
20         <html xmlns="http://www.w3.org/1999/xhtml">
21         <head>
22         <title>Index of /libreoffice/stable</title>
23         <link rel="stylesheet" href="/mirrorbrain.css" type="text/css" />
24         </head>
25         <body>
26         <h1>Index of /libreoffice/stable</h1>
27         <table><tr><th>&nbsp;</th><th><a href="?C=N;O=D">Name</a></th><th><a href="?C=M;O=A">Last modified</a></th><th><a href="?C=S;O=A">Size</a></th><th>Metadata</th></tr><tr><th colspan="5"><hr /></th></tr>
28         <tr><td valign="top">&nbsp;</td><td><a href="/libreoffice/">Parent Directory</a></td><td>&nbsp;</td><td align="right">  - </td><td>&nbsp;</td></tr>
29         <tr><td valign="top">&nbsp;</td><td><a href="7.2.7/">7.2.7/</a></td><td align="right">10-Mar-2022 11:12  </td><td align="right">  - </td><td>&nbsp;</td></tr>
30         <tr><td valign="top">&nbsp;</td><td><a href="7.3.3/">7.3.3/</a></td><td align="right">12-May-2022 10:06  </td><td align="right">  - </td><td>&nbsp;</td></tr>
31         <tr><td valign="top">&nbsp;</td><td><a href="7.2.6/">7.2.6/</a></td><td align="right">05-May-2022 07:57  </td><td align="right">  - </td><td>&nbsp;</td></tr>
32         <tr><th colspan="5"><hr /></th></tr>
33         </table>
34         <address>Apache Server at <a href="mailto:hostmaster@documentfoundation.org">download.documentfoundation.org</a> Port 80</address>
35         <br/><address><a href="http://mirrorbrain.org/">MirrorBrain</a> powered by <a href="http://httpd.apache.org/">Apache</a></address>
36         </body></html>
37       '';
39       actual = extractLatestVersionFromHtml latestVersionHtmlMock;
41     in
42     "7.3.3" == actual;
44   "should extract latest stable version from website" =
45     (builtins.compareVersions getLatestStableVersion "7.3.3") >= 0;
47   "should extract sha256 from html" =
48     let
49       sha256Html = "50ed3deb8d9c987516e2687ebb865bca15486c69da79f1b6d74381e43f2ec863  LibreOffice_7.3.3_MacOS_aarch64.dmg\n";
50       actual = extractSha256FromHtml sha256Html;
51     in
52     "50ed3deb8d9c987516e2687ebb865bca15486c69da79f1b6d74381e43f2ec863" == actual;