Deal with large numerical values in statistics - fixes #87

Change-Id: Iaaf95fe1dd6c87c693446706d2845a80bb2d257f
diff --git a/t/corpus_info.t b/t/corpus_info.t
index 551d052..e174bf0 100644
--- a/t/corpus_info.t
+++ b/t/corpus_info.t
@@ -27,10 +27,11 @@
 # Query passed
 $t->get_ok('/corpus')
   ->status_is(200)
-  ->json_is('/documents', 11)
-  ->json_is('/tokens', 665842)
-  ->json_is('/sentences', 25074)
-  ->json_is('/paragraphs', 772)
+  ->content_like(qr!"tokens":5991667065!)
+  ->json_is('/documents', 20216975)
+  ->json_is('/tokens', 5991667065)
+  ->json_is('/sentences', 403923016)
+  ->json_is('/paragraphs', 129385487)
   ->header_isnt('X-Kalamar-Cache', 'true')
   ;
 
@@ -51,10 +52,11 @@
 # Query passed
 $t->get_ok('/corpus')
   ->status_is(200)
-  ->json_is('/documents', 11)
-  ->json_is('/tokens', 665842)
-  ->json_is('/sentences', 25074)
-  ->json_is('/paragraphs', 772)
+  ->content_like(qr!"tokens":5991667065!)
+  ->json_is('/documents', 20216975)
+  ->json_is('/tokens', 5991667065)
+  ->json_is('/sentences', 403923016)
+  ->json_is('/paragraphs', 129385487)
   ->header_is('X-Kalamar-Cache', 'true')
   ;
 
diff --git a/t/corpus_info_cache.t b/t/corpus_info_cache.t
new file mode 100644
index 0000000..916a2d7
--- /dev/null
+++ b/t/corpus_info_cache.t
@@ -0,0 +1,68 @@
+use Mojo::Base -strict;
+use Test::Mojo;
+use Test::More;
+use Mojo::File qw/path/;
+
+
+#####################
+# Start Fake server #
+#####################
+my $mount_point = '/api/';
+$ENV{KALAMAR_API} = $mount_point;
+
+# New test with new cache
+my $t = Test::Mojo->new('Kalamar' => {
+  Kalamar => {},
+  CHI => {
+    default => {
+      driver => 'Memory',
+      global => 1,
+    },
+    default => {
+      driver => 'Memory',
+      global => 1,
+    },
+  }
+});
+
+is($t->app->config('CHI')->{default}->{serializer}, 'JSON');
+
+is($t->app->chi->driver_class, 'CHI::Driver::Memory');
+
+# Mount fake backend
+# Get the fixture path
+my $fixtures_path = path(Mojo::File->new(__FILE__)->dirname, 'server');
+my $fake_backend = $t->app->plugin(
+  Mount => {
+    $mount_point =>
+      $fixtures_path->child('mock.pl')
+  }
+);
+# Configure fake backend
+$fake_backend->pattern->defaults->{app}->log($t->app->log);
+
+# Query passed
+$t->get_ok('/corpus')
+  ->status_is(200)
+  ->content_like(qr!"tokens":5991667065!)
+  ->json_is('/documents', 20216975)
+  ->json_is('/tokens', 5991667065)
+  ->json_is('/sentences', 403923016)
+  ->json_is('/paragraphs', 129385487)
+  ->header_isnt('X-Kalamar-Cache', 'true')
+  ;
+
+# Query passed
+$t->get_ok('/corpus')
+  ->status_is(200)
+  ->content_like(qr!"tokens":5991667065!)
+  ->json_is('/documents', 20216975)
+  ->json_is('/tokens', 5991667065)
+  ->json_is('/sentences', 403923016)
+  ->json_is('/paragraphs', 129385487)
+  ->header_is('X-Kalamar-Cache', 'true')
+  ;
+
+
+done_testing;
+__END__
diff --git a/t/fixtures/response_corpusinfo.json b/t/fixtures/response_corpusinfo.json
index 1918da5..ad24f48 100644
--- a/t/fixtures/response_corpusinfo.json
+++ b/t/fixtures/response_corpusinfo.json
@@ -1,9 +1,9 @@
 {
   "status" : 200,
   "json" : {
-    "documents":11,
-    "tokens":665842,
-    "sentences":25074,
-    "paragraphs":772
+    "documents":20216975,
+    "tokens":5991667065,
+    "sentences":403923016,
+    "paragraphs":129385487
   }
 }