Skip to content

Commit e879526

Browse files
fix: resolve TestAPI/Error/DuringInjection flake (#19407)
Resolves coder/internal#905
1 parent c7cfa65 commit e879526

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

agent/agentcontainers/api_test.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2096,9 +2096,6 @@ func TestAPI(t *testing.T) {
20962096
}
20972097
)
20982098

2099-
coderBin, err := os.Executable()
2100-
require.NoError(t, err)
2101-
21022099
// Mock the `List` function to always return the test container.
21032100
mCCLI.EXPECT().List(gomock.Any()).Return(codersdk.WorkspaceAgentListContainersResponse{
21042101
Containers: []codersdk.WorkspaceAgentContainer{testContainer},
@@ -2139,7 +2136,7 @@ func TestAPI(t *testing.T) {
21392136
require.Equal(t, http.StatusOK, rec.Code)
21402137

21412138
var response codersdk.WorkspaceAgentListContainersResponse
2142-
err = json.NewDecoder(rec.Body).Decode(&response)
2139+
err := json.NewDecoder(rec.Body).Decode(&response)
21432140
require.NoError(t, err)
21442141

21452142
// Then: We expect that there will be an error associated with the devcontainer.
@@ -2149,16 +2146,16 @@ func TestAPI(t *testing.T) {
21492146
gomock.InOrder(
21502147
mCCLI.EXPECT().DetectArchitecture(gomock.Any(), testContainer.ID).Return(runtime.GOARCH, nil),
21512148
mCCLI.EXPECT().ExecAs(gomock.Any(), testContainer.ID, "root", "mkdir", "-p", "/.coder-agent").Return(nil, nil),
2152-
mCCLI.EXPECT().Copy(gomock.Any(), testContainer.ID, coderBin, "/.coder-agent/coder").Return(nil),
2149+
mCCLI.EXPECT().Copy(gomock.Any(), testContainer.ID, gomock.Any(), "/.coder-agent/coder").Return(nil),
21532150
mCCLI.EXPECT().ExecAs(gomock.Any(), testContainer.ID, "root", "chmod", "0755", "/.coder-agent", "/.coder-agent/coder").Return(nil, nil),
21542151
mCCLI.EXPECT().ExecAs(gomock.Any(), testContainer.ID, "root", "/bin/sh", "-c", "chown $(id -u):$(id -g) /.coder-agent/coder").Return(nil, nil),
21552152
)
21562153

21572154
// Given: We allow creation to succeed.
21582155
testutil.RequireSend(ctx, t, fSAC.createErrC, nil)
21592156

2160-
_, aw := mClock.AdvanceNext()
2161-
aw.MustWait(ctx)
2157+
err = api.RefreshContainers(ctx)
2158+
require.NoError(t, err)
21622159

21632160
req = httptest.NewRequest(http.MethodGet, "/", nil)
21642161
rec = httptest.NewRecorder()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy