@@ -17,7 +17,6 @@ package daemon_test
1717
1818import (
1919 "context"
20- "encoding/json"
2120 "fmt"
2221 "io"
2322 "testing"
@@ -35,35 +34,6 @@ func TestDaemonBundleLibInstall(t *testing.T) {
3534 fmt .Printf ("INIT> %v\n " , ir .GetMessage ())
3635 }))
3736
38- // Install libraries in bundled dir (should fail)
39- {
40- instCl , err := grpcInst .LibraryInstall (context .Background (), "Arduino_BuiltIn" , "" , false , false , true )
41- require .NoError (t , err )
42- for {
43- msg , err := instCl .Recv ()
44- if err == io .EOF {
45- require .FailNow (t , "LibraryInstall is supposed to fail because builtin libraries directory is not set" )
46- }
47- if err != nil {
48- fmt .Println ("LIB INSTALL ERROR:" , err )
49- break
50- }
51- fmt .Printf ("LIB INSTALL> %+v\n " , msg )
52- }
53- }
54-
55- // Set builtin libraries dir
56- builtinLibsDir := cli .DataDir ().Join ("libraries" )
57- jsonBuiltinLibsDir , err := json .Marshal (builtinLibsDir )
58- require .NoError (t , err )
59- err = cli .SetValue ("directories.builtin.libraries" , string (jsonBuiltinLibsDir ))
60- require .NoError (t , err )
61-
62- // Re-init
63- require .NoError (t , grpcInst .Init ("" , "" , func (ir * commands.InitResponse ) {
64- fmt .Printf ("INIT> %v\n " , ir .GetMessage ())
65- }))
66-
6737 // Install libraries in bundled dir
6838 {
6939 instCl , err := grpcInst .LibraryInstall (context .Background (), "Arduino_BuiltIn" , "" , false , false , true )
@@ -123,4 +93,30 @@ func TestDaemonBundleLibInstall(t *testing.T) {
12393 require .Equal (t , libsAndLocation ["SD" ], commands .LibraryLocation_LIBRARY_LOCATION_BUILTIN )
12494 require .Equal (t , libsAndLocation ["Firmata" ], commands .LibraryLocation_LIBRARY_LOCATION_BUILTIN )
12595 }
96+
97+ // Un-Set builtin libraries dir
98+ err := cli .SetValue ("directories.builtin.libraries" , `""` )
99+ require .NoError (t , err )
100+
101+ // Re-init
102+ require .NoError (t , grpcInst .Init ("" , "" , func (ir * commands.InitResponse ) {
103+ fmt .Printf ("INIT> %v\n " , ir .GetMessage ())
104+ }))
105+
106+ // Install libraries in bundled dir (should now fail)
107+ {
108+ instCl , err := grpcInst .LibraryInstall (context .Background (), "Arduino_BuiltIn" , "" , false , false , true )
109+ require .NoError (t , err )
110+ for {
111+ msg , err := instCl .Recv ()
112+ if err == io .EOF {
113+ require .FailNow (t , "LibraryInstall is supposed to fail because builtin libraries directory is not set" )
114+ }
115+ if err != nil {
116+ fmt .Println ("LIB INSTALL ERROR:" , err )
117+ break
118+ }
119+ fmt .Printf ("LIB INSTALL> %+v\n " , msg )
120+ }
121+ }
126122}
0 commit comments