Skip to content

Commit e354bd6

Browse files
committed
Added test for arduino#1529
1 parent a82b8b4 commit e354bd6

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
@@ -458,3 +458,11 @@ func (inst *ArduinoCLIInstance) UpdateIndex(ctx context.Context, ignoreCustomPac
458458
logCallf(">>> UpdateIndex(%+v)\n", req)
459459
return updCl, err
460460
}
461+
462+
// PlatformList calls the "PlatformList" gRPC method.
463+
func (inst *ArduinoCLIInstance) PlatformList(ctx context.Context) (*commands.PlatformListResponse, error) {
464+
req := &commands.PlatformListRequest{Instance: inst.instance}
465+
logCallf(">>> PlatformList(%+v)\n", req)
466+
resp, err := inst.cli.daemonClient.PlatformList(ctx, req)
467+
return resp, err
468+
}

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)