Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2f13214

Browse files
fix: only run project discovery when agentDirectory is not empty
We make sure to only run project discovery when the agent directory isnot empty. If we attempt to do project discovery when the agentdirectory is empty we will just get an error.
1 parentd463ed5 commit2f13214

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

‎agent/agentcontainers/api.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ func (api *API) Start() {
398398
return
399399
}
400400

401-
ifapi.projectDiscovery {
401+
ifapi.projectDiscovery&&api.agentDirectory!=""{
402402
api.discoverDone=make(chanstruct{})
403403

404404
goapi.discover()

‎agent/agentcontainers/api_test.go‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3425,4 +3425,29 @@ func TestDevcontainerDiscovery(t *testing.T) {
34253425
require.Equal(t,tt.expected,got.Devcontainers)
34263426
})
34273427
}
3428+
3429+
t.Run("NoErrorWhenAgentDirAbsent",func(t*testing.T) {
3430+
t.Parallel()
3431+
3432+
logger:=testutil.Logger(t)
3433+
3434+
// Given: We have an empty agent directory
3435+
agentDir:=""
3436+
3437+
api:=agentcontainers.NewAPI(logger,
3438+
agentcontainers.WithWatcher(watcher.NewNoop()),
3439+
agentcontainers.WithManifestInfo("owner","workspace","parent-agent",agentDir),
3440+
agentcontainers.WithContainerCLI(&fakeContainerCLI{}),
3441+
agentcontainers.WithDevcontainerCLI(&fakeDevcontainerCLI{}),
3442+
agentcontainers.WithProjectDiscovery(true),
3443+
)
3444+
3445+
// When: We start and close the API
3446+
api.Start()
3447+
api.Close()
3448+
3449+
// Then: We expect there to have been no errors.
3450+
// This is implicitly handled by `testutil.Logger` failing when it
3451+
// detects an error has been logged.
3452+
})
34283453
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp