Skip to content

Commit 6c5bfec

Browse files
committed
Added tests for user-installed libraries
1 parent 2ec364d commit 6c5bfec

File tree

9 files changed

+116
-3
lines changed

9 files changed

+116
-3
lines changed

Gopkg.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

commands/commands_test.go

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,40 @@ func TestLibSearch(t *testing.T) {
169169
require.Equal(t, "", string(output))
170170
}
171171

172+
func TestUserLibs(t *testing.T) {
173+
defer makeTempDataDir(t)()
174+
defer makeTempSketchbookDir(t)()
175+
libDir := currSketchbookDir.Join("libraries")
176+
err := libDir.MkdirAll()
177+
require.NoError(t, err, "creating 'sketchbook/libraries' dir")
178+
179+
installLib := func(lib string) {
180+
libPath := paths.New("testdata/" + lib)
181+
fmt.Printf("COPYING: %s in %s\n", libPath, libDir)
182+
err = libPath.CopyDirTo(libDir.Join(lib))
183+
require.NoError(t, err, "copying "+lib+" in sketchbook")
184+
}
185+
186+
// List libraries (valid libs)
187+
installLib("MyLib")
188+
exitCode, d := executeWithArgs(t, "lib", "list")
189+
require.Zero(t, exitCode, "exit code")
190+
require.Contains(t, string(d), "MyLib")
191+
require.Contains(t, string(d), "1.0.5")
192+
193+
// List libraries (pre-1.5 format)
194+
installLib("MyLibPre15")
195+
exitCode, d = executeWithArgs(t, "lib", "list")
196+
require.Zero(t, exitCode, "exit code")
197+
require.Contains(t, string(d), "MyLibPre15")
198+
199+
// List libraries (invalid version lib)
200+
installLib("MyLibWithWrongVersion")
201+
exitCode, d = executeWithArgs(t, "lib", "list")
202+
require.Zero(t, exitCode, "exit code")
203+
require.Contains(t, string(d), "MyLibWithWrongVersion")
204+
}
205+
172206
func TestLibDownloadAndInstall(t *testing.T) {
173207
defer makeTempDataDir(t)()
174208
defer makeTempSketchbookDir(t)()
@@ -269,7 +303,6 @@ func TestLibDownloadAndInstall(t *testing.T) {
269303
exitCode, d = executeWithArgs(t, "lib", "list")
270304
require.Zero(t, exitCode, "exit code")
271305
require.NotContains(t, string(d), "Audio")
272-
273306
}
274307

275308
func updateCoreIndex(t *testing.T) {

commands/testdata/MyLib/MyLib.h

Whitespace-only changes.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name=MyLib
2+
version=1.0.5
3+
author=Arduino
4+
maintainer=Arduino <[email protected]>
5+
sentence=A test lib
6+
paragraph=A very cool test lib
7+
category=Signal Input/Output
8+
url=http://www.arduino.cc/en/Reference/Audio
9+
architectures=*

commands/testdata/MyLibPre15/MyLibPre15.h

Whitespace-only changes.

commands/testdata/MyLibPre15/utility/util.h

Whitespace-only changes.

commands/testdata/MyLibWithWrongVersion/MyLibWithWrongVersion.h

Whitespace-only changes.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name=MyLibWithWrongVersion
2+
version=2.0a
3+
author=Arduino
4+
maintainer=Arduino <[email protected]>
5+
sentence=A test lib
6+
paragraph=A very bad test lib
7+
category=Signal Input/Output
8+
url=http://www.arduino.cc/en/Reference/Audio
9+
architectures=*

vendor/github.com/arduino/go-paths-helper/paths.go

Lines changed: 62 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)