Skip to content

Commit a64ad8c

Browse files
committed
Added test for #1529
1 parent c1760bd commit a64ad8c

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

Diff for: internal/integrationtest/arduino-cli.go

+8
Original file line numberDiff line numberDiff line change
@@ -457,3 +457,11 @@ func (inst *ArduinoCLIInstance) UpdateIndex(ctx context.Context, ignoreCustomPac
457457
logCallf(">>> UpdateIndex(%+v)\n", req)
458458
return updCl, err
459459
}
460+
461+
// PlatformList calls the "PlatformList" gRPC method.
462+
func (inst *ArduinoCLIInstance) PlatformList(ctx context.Context) (*commands.PlatformListResponse, error) {
463+
req := &commands.PlatformListRequest{Instance: inst.instance}
464+
logCallf(">>> PlatformList(%+v)\n", req)
465+
resp, err := inst.cli.daemonClient.PlatformList(ctx, req)
466+
return resp, err
467+
}

Diff for: internal/integrationtest/daemon/daemon_test.go

+17
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,23 @@ func TestArduinoCliDaemon(t *testing.T) {
8181
testWatcher()
8282
}
8383

84+
func TestDaemonAutoUpdateIndexOnFirstInit(t *testing.T) {
85+
// https://github.com/arduino/arduino-cli/issues/1529
86+
87+
env, cli := createEnvForDaemon(t)
88+
defer env.CleanUp()
89+
90+
grpcInst := cli.Create()
91+
require.NoError(t, grpcInst.Init("", "", func(ir *commands.InitResponse) {
92+
fmt.Printf("INIT> %v\n", ir.GetMessage())
93+
}))
94+
95+
_, err := grpcInst.PlatformList(context.Background())
96+
require.NoError(t, err)
97+
98+
require.FileExists(t, cli.DataDir().Join("package_index.json").String())
99+
}
100+
84101
// createEnvForDaemon performs the minimum required operations to start the arduino-cli daemon.
85102
// It returns a testsuite.Environment and an ArduinoCLI client to perform the integration tests.
86103
// The Environment must be disposed by calling the CleanUp method via defer.

0 commit comments

Comments
 (0)