summaryrefslogtreecommitdiffstats
path: root/vespaclient/src/perl/test/Yahoo/Vespa/ConsoleOutputTest.pl
blob: bd398a5b9f76a3990935b2fcebd0daac0ef085c0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

use Test::More;

BEGIN { use_ok( 'Yahoo::Vespa::ConsoleOutput' ); }
require_ok( 'Yahoo::Vespa::ConsoleOutput' );

ok( Yahoo::Vespa::ConsoleOutput::getVerbosity() == 3,
    'Default verbosity is 3' );
ok( Yahoo::Vespa::ConsoleOutput::usingAnsiColors(),
    'Using ansi colors by default' );

use TestUtils::VespaTest;

printSpam "test\n";
isOutput('', '', "No spam at level 3");

printDebug "test\n";
isOutput('', '', "No spam at level 3");

printInfo "info test\n";
isOutput("info test\n", '', "Info at level 3");

printWarning "foo\n";
isOutput("", "\e[93mfoo\e[0m\n", "Stderr output for warning");

useColors(0);
printWarning "foo\n";
isOutput("", "foo\n", "Stderr output without ansi colors");

Yahoo::Vespa::ConsoleOutput::setVerbosity(4);
printSpam "test\n";
isOutput('', '', "No spam at level 4");

printDebug "test\n";
isOutput("debug: test\n", '', "Debug at level 4");

Yahoo::Vespa::ConsoleOutput::setVerbosity(5);
printSpam "test\n";
isOutput("spam: test\n", '', "Spam at level 5");

printInfo "info test\n";
isOutput("info: info test\n", '', "Type prefix at high verbosity");

done_testing();

exit(0);