Skip to content

Commit 85b9519

Browse files
committed
More tests.
1 parent d82bd40 commit 85b9519

File tree

2 files changed

+124
-6
lines changed

2 files changed

+124
-6
lines changed

Diff for: commands/lib/search_test.go

+41-6
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828

2929
var customIndexPath = paths.New("testdata", "test1")
3030
var fullIndexPath = paths.New("testdata", "full")
31+
var qualifiedSearchIndexPath = paths.New("testdata", "qualified_search")
3132

3233
func TestSearchLibrary(t *testing.T) {
3334
lm := librariesmanager.NewLibraryManager(customIndexPath, nil)
@@ -96,7 +97,7 @@ func TestSearchLibraryFields(t *testing.T) {
9697
}
9798

9899
func TestSearchLibraryWithQualifiers(t *testing.T) {
99-
lm := librariesmanager.NewLibraryManager(fullIndexPath, nil)
100+
lm := librariesmanager.NewLibraryManager(qualifiedSearchIndexPath, nil)
100101
lm.LoadIndex()
101102

102103
query := func(q string) []string {
@@ -107,14 +108,48 @@ func TestSearchLibraryWithQualifiers(t *testing.T) {
107108
return libs
108109
}
109110

110-
res := query("name:FlashStorage")
111-
require.Len(t, res, 7)
111+
res := query("mesh")
112+
require.Len(t, res, 4)
112113

113-
res = query("name=FlashStorage")
114-
require.Len(t, res, 1)
115-
require.Equal(t, "FlashStorage", res[0])
114+
res = query("name:Mesh")
115+
require.Len(t, res, 3)
116+
117+
res = query("name=Mesh")
118+
require.Len(t, res, 0)
116119

120+
// Space not in double-quoted string
121+
res = query("name=Painless Mesh")
122+
require.Len(t, res, 0)
123+
124+
// Embedded space in double-quoted string
117125
res = query("name=\"Painless Mesh\"")
118126
require.Len(t, res, 1)
119127
require.Equal(t, "Painless Mesh", res[0])
128+
129+
// No closing double-quote - still tokenizes with embedded space
130+
res = query("name:\"Painless Mesh")
131+
require.Len(t, res, 1)
132+
133+
// Malformed double-quoted string with escaped first double-quote
134+
res = query("name:\\\"Painless Mesh\"")
135+
require.Len(t, res, 0)
136+
137+
res = query("name:mesh author:TMRh20")
138+
require.Len(t, res, 1)
139+
require.Equal(t, "RF24Mesh", res[0])
140+
141+
res = query("mesh dependencies:ArduinoJson")
142+
require.Len(t, res, 1)
143+
require.Equal(t, "Painless Mesh", res[0])
144+
145+
res = query("architectures:esp author=\"Suraj I.\"")
146+
require.Len(t, res, 1)
147+
require.Equal(t, "esp8266-framework", res[0])
148+
149+
res = query("mesh esp")
150+
require.Len(t, res, 2)
151+
152+
res = query("mesh esp paragraph:wifi")
153+
require.Len(t, res, 1)
154+
require.Equal(t, "esp8266-framework", res[0])
120155
}
+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
{
2+
"libraries": [
3+
{
4+
"name": "esp8266-framework",
5+
"version": "1.1.5",
6+
"author": "Suraj I.",
7+
"maintainer": "Suraj I. \u003c[email protected]\u003e",
8+
"sentence": "esp8266 framework stack for easy configurable applications",
9+
"paragraph": "esp8266 framework includes all services like gpio, wifi, http, mqtt, ntp, ota, napt, espnow, mesh, server etc. which are ready to use in all applications",
10+
"website": "https://github.com/Suraj151/esp8266-framework",
11+
"category": "Communication",
12+
"architectures": ["esp8266"],
13+
"types": ["Contributed"],
14+
"repository": "https://github.com/Suraj151/esp8266-framework.git",
15+
"url": "https://downloads.arduino.cc/libraries/github.com/Suraj151/esp8266_framework-1.1.5.zip",
16+
"archiveFileName": "esp8266_framework-1.1.5.zip",
17+
"size": 1918535,
18+
"checksum": "SHA-256:81731d4ccc80846c317a2d4e2086d32caa695ed97d3e4765a59c5651b4be30b5"
19+
},
20+
{
21+
"name": "Painless Mesh",
22+
"version": "1.5.0",
23+
"author": "Coopdis,Scotty Franzyshen,Edwin van Leeuwen,Germán Martín,Maximilian Schwarz,Doanh Doanh",
24+
"maintainer": "Edwin van Leeuwen",
25+
"sentence": "A painless way to setup a mesh with ESP8266 and ESP32 devices",
26+
"paragraph": "A painless way to setup a mesh with ESP8266 and ESP32 devices",
27+
"website": "https://gitlab.com/painlessMesh/painlessMesh",
28+
"category": "Communication",
29+
"architectures": ["esp8266", "esp32"],
30+
"types": ["Contributed"],
31+
"repository": "https://gitlab.com/painlessMesh/painlessMesh.git",
32+
"providesIncludes": ["painlessMesh.h"],
33+
"dependencies": [
34+
{
35+
"name": "ArduinoJson"
36+
},
37+
{
38+
"name": "TaskScheduler"
39+
}
40+
],
41+
"url": "https://downloads.arduino.cc/libraries/gitlab.com/painlessMesh/Painless_Mesh-1.5.0.zip",
42+
"archiveFileName": "Painless_Mesh-1.5.0.zip",
43+
"size": 293531,
44+
"checksum": "SHA-256:9d965064fc704e8ba19c0452cc50e619145f7869b9b135dbf7e521f6ec0a4b33"
45+
},
46+
{
47+
"name": "RF24Mesh",
48+
"version": "1.0.0",
49+
"author": "TMRh20",
50+
"maintainer": "TMRh20",
51+
"sentence": "A library for NRF24L01(+) devices mesh.",
52+
"paragraph": "Provides a simple and seamless 'mesh' layer for sensor networks, allowing automatic and dynamic configuration that can be customized to suit many scenarios. It is currently designed to interface directly with with the RF24Network Development library, an OSI Network Layer using nRF24L01(+) radios driven by the newly optimized RF24 library fork.",
53+
"website": "http://tmrh20.github.io/RF24Mesh/",
54+
"category": "Communication",
55+
"architectures": ["avr"],
56+
"types": ["Contributed"],
57+
"repository": "https://github.com/TMRh20/RF24Mesh.git",
58+
"url": "https://downloads.arduino.cc/libraries/github.com/TMRh20/RF24Mesh-1.0.0.zip",
59+
"archiveFileName": "RF24Mesh-1.0.0.zip",
60+
"size": 31419,
61+
"checksum": "SHA-256:1b122a6412bc06a33a7fbcef34e2210d0990c25839fd7bc547604103f28194b5"
62+
},
63+
{
64+
"name": "DLLN3X ZigBee Mesh Module Library",
65+
"version": "1.0.1",
66+
"author": "Duke Liu \u003c[email protected]\u003e",
67+
"maintainer": "Duke Liu \u003c[email protected]\u003e",
68+
"license": "MIT",
69+
"sentence": "This library allows you to use DLLN3X ZigBee mesh module very easily.",
70+
"paragraph": "This library currently allows basic send and receive operations using the DLLN3X module, with more features to come.",
71+
"website": "https://github.com/mentalfl0w/DLLN3X_zigbee_mesh_module_library",
72+
"category": "Communication",
73+
"architectures": ["*"],
74+
"types": ["Contributed"],
75+
"repository": "https://github.com/mentalfl0w/DLLN3X_zigbee_mesh_module_library.git",
76+
"providesIncludes": ["DLLN3X.h"],
77+
"url": "https://downloads.arduino.cc/libraries/github.com/mentalfl0w/DLLN3X_ZigBee_Mesh_Module_Library-1.0.1.zip",
78+
"archiveFileName": "DLLN3X_ZigBee_Mesh_Module_Library-1.0.1.zip",
79+
"size": 6122,
80+
"checksum": "SHA-256:a28833bbd575ef8deab744a1f0e1175dad9e5329bf5c620fc2fe53e1de1d32ba"
81+
}
82+
]
83+
}

0 commit comments

Comments
 (0)