@@ -4,7 +4,7 @@ import { fsselect } from "./mod.ts";
44
55Deno . test ( "if 'select * from .' works" , async ( ) => {
66 const result = await fsselect ( "select * from ." ) ;
7- assert ( result . length === 18 ) ;
7+ assert ( result . length === 20 ) ;
88} ) ;
99
1010Deno . test ( "if 'select * from root' works" , async ( ) => {
@@ -147,4 +147,76 @@ Deno.test("if select * from root where name <> 'root.txt' works", async () => {
147147 "test_folder_with_folder" ,
148148 ] ;
149149 assertArrayIncludes < string > ( names , expectedNames ) ;
150+ } ) ;
151+
152+ Deno . test ( "if select * from root where name like 'test_%' works" , async ( ) => {
153+ const result = await fsselect ( "select * from root where name like 'test_%'" ) ;
154+ assert ( result . length === 3 ) ;
155+
156+ const names = result . map ( ( i ) => i . name as string ) ;
157+ const expectedNames = [
158+ "test_folder_with_file" ,
159+ "test_folder_with_files" ,
160+ "test_folder_with_folder" ,
161+ ] ;
162+ assertArrayIncludes < string > ( names , expectedNames ) ;
163+ } ) ;
164+
165+ Deno . test ( "if select * from root where name like '%folder%' works" , async ( ) => {
166+ const result = await fsselect ( "select * from root where name like '%folder%'" ) ;
167+ assert ( result . length === 3 ) ;
168+
169+ const names = result . map ( ( i ) => i . name as string ) ;
170+ const expectedNames = [
171+ "test_folder_with_file" ,
172+ "test_folder_with_files" ,
173+ "test_folder_with_folder" ,
174+ ] ;
175+ assertArrayIncludes < string > ( names , expectedNames ) ;
176+ } ) ;
177+
178+ Deno . test ( "if select * from root where name like '%.txt' works" , async ( ) => {
179+ const result = await fsselect ( "select * from root where name like '%.txt'" ) ;
180+ assert ( result . length === 1 ) ;
181+
182+ const names = result . map ( ( i ) => i . name as string ) ;
183+ const expectedNames = [
184+ "root.txt"
185+ ] ;
186+ assertArrayIncludes < string > ( names , expectedNames ) ;
187+ } ) ;
188+
189+ Deno . test ( "if select * from root where name like '%with_file%' works" , async ( ) => {
190+ const result = await fsselect ( "select * from root where name like '%with_file%'" ) ;
191+ assert ( result . length === 2 ) ;
192+
193+ const names = result . map ( ( i ) => i . name as string ) ;
194+ const expectedNames = [
195+ "test_folder_with_file" ,
196+ "test_folder_with_files" ,
197+ ] ;
198+ assertArrayIncludes < string > ( names , expectedNames ) ;
199+ } ) ;
200+
201+ Deno . test ( "if select * from root where name like 'some' does not return entries" , async ( ) => {
202+ const result = await fsselect ( "select * from root where name like 'some'" ) ;
203+ assert ( result . length === 0 ) ;
204+
205+ const names = result . map ( ( i ) => i . name as string ) ;
206+ const expectedNames : string [ ] = [ ] ;
207+ assertArrayIncludes < string > ( names , expectedNames ) ;
208+ } ) ;
209+
210+ Deno . test ( "if select * from root where name like '%%' works" , async ( ) => {
211+ const result = await fsselect ( "select * from root where name like '%%'" ) ;
212+ assert ( result . length === 4 ) ;
213+
214+ const names = result . map ( ( i ) => i . name as string ) ;
215+ const expectedNames = [
216+ "test_folder_with_file" ,
217+ "test_folder_with_files" ,
218+ "test_folder_with_folder" ,
219+ "root.txt"
220+ ] ;
221+ assertArrayIncludes < string > ( names , expectedNames ) ;
150222} ) ;
0 commit comments