1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 module test_commands_catalog
is test
18 import doc
::commands
::commands_catalog
20 class TestCommandsCatalog
24 # Catalog used for tests
25 var test_catalog
: Catalog is lazy
do
26 var catalog
= new Catalog(test_builder
)
29 for p
in test_view
.mpackages
do
32 test_builder
.scan_group
(g
)
34 catalog
.deps
.add_node
(p
)
35 for gg
in p
.mgroups
do for m
in gg
.mmodules
do
36 for im
in m
.in_importation
.direct_greaters
do
38 if ip
== null or ip
== p
then continue
39 test_catalog
.deps
.add_edge
(p
, ip
)
44 for mpackage
in test_view
.mpackages
do
45 catalog
.package_page
(mpackage
)
46 catalog
.git_info
(mpackage
)
47 catalog
.mpackage_stats
(mpackage
)
52 fun test_cmd_catalog
is test
do
53 var cmd
= new CmdCatalogPackages(test_view
, test_catalog
)
54 var res
= cmd
.init_command
55 assert res
isa CmdSuccess
56 assert cmd
.results
.as(not null).first
.full_name
== "test_prog"
59 fun test_cmd_catalog_search
is test
do
60 var cmd
= new CmdCatalogSearch(test_view
, test_catalog
, "test")
61 var res
= cmd
.init_command
62 assert res
isa CmdSuccess
63 assert cmd
.results
.as(not null).first
.full_name
== "test_prog"
64 assert cmd
.results
.as(not null).first
isa MPackage
67 fun test_cmd_catalog_stats
is test
do
68 var cmd
= new CmdCatalogStats(test_view
, test_catalog
)
69 var res
= cmd
.init_command
70 assert res
isa CmdSuccess
71 assert cmd
.stats
!= null
74 fun test_cmd_catalog_tags
is test
do
75 var cmd
= new CmdCatalogTags(test_view
, test_catalog
)
76 var res
= cmd
.init_command
77 assert res
isa CmdSuccess
78 assert cmd
.packages_count_by_tags
.as(not null).length
== 2
81 fun test_cmd_catalog_tag
is test
do
82 var cmd
= new CmdCatalogTag(test_view
, test_catalog
, "test")
83 var res
= cmd
.init_command
84 assert res
isa CmdSuccess
85 assert cmd
.tag
== "test"
86 assert cmd
.results
.as(not null).length
== 1
89 fun test_cmd_catalog_person
is test
do
90 var cmd
= new CmdCatalogPerson(test_view
, test_catalog
, person_name
= "Alexandre Terrasa")
91 var res
= cmd
.init_command
92 assert res
isa CmdSuccess
93 assert cmd
.person
.as(not null).name
== "Alexandre Terrasa"
96 fun test_cmd_catalog_contributing
is test
do
97 var cmd
= new CmdCatalogContributing(test_view
, test_catalog
,
98 person_name
= "Alexandre Terrasa")
99 var res
= cmd
.init_command
100 assert res
isa CmdSuccess
101 assert cmd
.person
.as(not null).name
== "Alexandre Terrasa"
102 assert cmd
.results
.as(not null).length
== 1
105 fun test_cmd_catalog_maintaining
is test
do
106 var cmd
= new CmdCatalogMaintaining(test_view
, test_catalog
,
107 person_name
= "Alexandre Terrasa")
108 var res
= cmd
.init_command
109 assert res
isa CmdSuccess
110 assert cmd
.person
.as(not null).name
== "Alexandre Terrasa"
111 assert cmd
.results
.as(not null).length
== 2