@@ -136,6 +136,40 @@ def test_output(self, vcz_path, tmp_path):
136
136
assert output .exists ()
137
137
138
138
139
+ class TestIndex :
140
+ def test_stats (self , vcz_path ):
141
+ result = run_vcztools (f"index -s { vcz_path } " )
142
+ assert list (result .splitlines ()) == ["19\t .\t 2" , "20\t .\t 6" , "X\t .\t 1" ]
143
+
144
+ def test_nrecords (self , vcz_path ):
145
+ result = run_vcztools (f"index -n { vcz_path } " )
146
+ assert list (result .splitlines ()) == ["9" ]
147
+
148
+ def test_stats_and_nrecords (self , vcz_path ):
149
+ runner = ct .CliRunner (mix_stderr = False )
150
+ result = runner .invoke (
151
+ cli .vcztools_main ,
152
+ f"index -ns { vcz_path } " ,
153
+ catch_exceptions = False ,
154
+ )
155
+ assert result .exit_code == 2
156
+ assert len (result .stdout ) == 0
157
+ assert len (result .stderr ) > 0
158
+ assert "Expected only one of --stats or --nrecords options" in result .stderr
159
+
160
+ def test_no_stats_or_nrecords (self , vcz_path ):
161
+ runner = ct .CliRunner (mix_stderr = False )
162
+ result = runner .invoke (
163
+ cli .vcztools_main ,
164
+ f"index { vcz_path } " ,
165
+ catch_exceptions = False ,
166
+ )
167
+ assert result .exit_code == 2
168
+ assert len (result .stdout ) == 0
169
+ assert len (result .stderr ) > 0
170
+ assert "Error: Building region indexes is not supported" in result .stderr
171
+
172
+
139
173
def test_top_level ():
140
174
runner = ct .CliRunner (mix_stderr = False )
141
175
result = runner .invoke (
0 commit comments