diff options
author | dakkar <dakkar@thenautilus.net> | 2018-01-02 17:18:39 +0000 |
---|---|---|
committer | dakkar <dakkar@thenautilus.net> | 2018-01-02 17:18:39 +0000 |
commit | cfe34795b1d9db7ada11d18c4f76444060cdf60d (patch) | |
tree | 98e5d5c5bd6731d0ae656a33374d5d211ae2abe0 | |
parent | test for musicfile (diff) | |
download | Ultramarine-cfe34795b1d9db7ada11d18c4f76444060cdf60d.tar.gz Ultramarine-cfe34795b1d9db7ada11d18c4f76444060cdf60d.tar.bz2 Ultramarine-cfe34795b1d9db7ada11d18c4f76444060cdf60d.zip |
better structure, and test, for License
-rw-r--r-- | lib/Ultramarine/Controller.pm6 | 7 | ||||
-rw-r--r-- | lib/Ultramarine/Model/License.pm6 | 10 | ||||
-rw-r--r-- | t/tests/model/license.t | 12 |
3 files changed, 21 insertions, 8 deletions
diff --git a/lib/Ultramarine/Controller.pm6 b/lib/Ultramarine/Controller.pm6 index 208a50b..f5cbd64 100644 --- a/lib/Ultramarine/Controller.pm6 +++ b/lib/Ultramarine/Controller.pm6 @@ -53,9 +53,14 @@ class Ultramarine::Controller { before $!authorisation; post -> 'ping' { respond [] } post -> 'getLicense' { + my $expires = $.license.expires-at.DateTime.truncated-to('second'); respond [ :status<ok>, - license => [ |%($.license.status) ], + license => [ + :valid($.license.is-valid.Str.lc), + :email($.license.email), + :licenseExpires($expires.yyyy-mm-dd ~ ':' ~ $expires.hh-mm-ss), + ], ], } post -> 'getMusicFolders' { diff --git a/lib/Ultramarine/Model/License.pm6 b/lib/Ultramarine/Model/License.pm6 index 2ceeaa5..26380e0 100644 --- a/lib/Ultramarine/Model/License.pm6 +++ b/lib/Ultramarine/Model/License.pm6 @@ -1,11 +1,7 @@ use v6.d.PREVIEW; class Ultramarine::Model::License { - method status() { - return { - :valid<true>, - :email<foo@bar.com>, - :licenseExpires<2019-01-01:00:00:00>, - } - } + method is-valid() { True } + method email() { 'foo@bar.com' } + method expires-at { now.DateTime.later(:2years).Instant } } diff --git a/t/tests/model/license.t b/t/tests/model/license.t new file mode 100644 index 0000000..d7e7993 --- /dev/null +++ b/t/tests/model/license.t @@ -0,0 +1,12 @@ +use v6.d.PREVIEW; +use Test; +use Ultramarine::Model::License; + +my Ultramarine::Model::License $l .= new; + +ok($l.is-valid,'the license should always be valid'); +ok($l.email,'the license should have an email address'); +ok($l.expires-at > now, 'the license should never expire'); + +done-testing; + |