Skip to content

Commit 5710d4a

Browse files
committed
Added test for #1529
1 parent d079aa3 commit 5710d4a

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
@@ -445,3 +445,11 @@ func (inst *ArduinoCLIInstance) UpdateIndex(ctx context.Context, ignoreCustomPac
445445
logCallf(">>> UpdateIndex(%+v)\n", req)
446446
return updCl, err
447447
}
448+
449+
// PlatformList calls the "PlatformList" gRPC method.
450+
func (inst *ArduinoCLIInstance) PlatformList(ctx context.Context) (*commands.PlatformListResponse, error) {
451+
req := &commands.PlatformListRequest{Instance: inst.instance}
452+
logCallf(">>> PlatformList(%+v)\n", req)
453+
resp, err := inst.cli.daemonClient.PlatformList(ctx, req)
454+
return resp, err
455+
}

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

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

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

0 commit comments

Comments
 (0)