]> iEval git - app-musicexpo.git/blame_incremental - t/musicexpo-cache.t
Bump version and update Changes
[app-musicexpo.git] / t / musicexpo-cache.t
... / ...
CommitLineData
1#!/usr/bin/perl -w
2use v5.14;
3use warnings;
4
5use Test::More tests => 3;
6
7use File::Temp qw/tempfile/;
8
9my $file;
10
11BEGIN {
12 $file = (tempfile UNLINK => 1)[1];
13 @ARGV = (-cache => $file, sort <empty*>);
14}
15BEGIN { use_ok('App::MusicExpo'); }
16
17close STDOUT;
18my $out;
19open STDOUT, '>', \$out;
20
21my %handled = map { $_ => 1 } App::MusicExpo::extensions_handled;
22
23my $prefix = '<tr><td class="title"><a href="#silence-cellule" data-hash="#silence-cellule">Cellule</a><td class="artist">Silence<td class="album">L&#39;autre endroit<td class="genre">Electro<td class="track">01/09<td class="year">2005<td class="formats">';
24
25my @lines;
26if ($handled{'.flac'} && $handled{'.ogg'}) {
27 push @lines, $prefix . '<a href="/music/empty.flac">FLAC</a> <a href="/music/empty.ogg">Vorbis</a> '
28} elsif ($handled{'.flac'}) {
29 push @lines, $prefix . '<a href="/music/empty.flac">FLAC</a> '
30} elsif ($handled{'.ogg'}) {
31 push @lines, $prefix . '<a href="/music/empty.ogg">Vorbis</a> '
32}
33
34push @lines, $prefix . '<a href="/music/empty2.opus">Opus</a> ' if $handled{'.opus'};
35push @lines, $prefix . '<a href="/music/empty3.mp3">MP3</a> ' if $handled{'.mp3'};
36push @lines, '<tr><td class="title"><a href="#silence-cellule" data-hash="#silence-cellule">Cellule</a><td class="artist">Silence<td class="album">L&#39;autre endroit<td class="genre">Electro<td class="track">1/9<td class="year">2005<td class="formats"><a href="/music/empty4.aac">AAC</a> ' if $handled{'.aac'};
37
38my $contents = join '', map { "\n$_" } @lines;
39
40App::MusicExpo->run;
41
42is $out, <<"OUT", 'output is correct';
43<!DOCTYPE html>
44<title>Music</title>
45<meta charset="utf-8">
46<link rel="stylesheet" href="musicexpo.css">
47<script async defer type="application/javascript" src="player.js"></script>
48
49<div id="player"></div>
50
51<table border>
52<thead>
53<tr><th>Title<th>Artist<th>Album<th>Genre<th>Track<th>Year<th>Type
54<tbody>$contents
55</table>
56OUT
57
58ok -e $file, 'cache exists';
This page took 0.031342 seconds and 5 git commands to generate.