MCPcopy Index your code
hub / github.com/coder/coder / TestWatchWorkspaceAgentDevcontainers

Function TestWatchWorkspaceAgentDevcontainers

coderd/workspaceagents_test.go:1556–1744  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1554}
1555
1556func TestWatchWorkspaceAgentDevcontainers(t *testing.T) {
1557 t.Parallel()
1558
1559 t.Run("OK", func(t *testing.T) {
1560 t.Parallel()
1561
1562 var (
1563 ctx = testutil.Context(t, testutil.WaitLong)
1564 logger = slogtest.Make(t, &slogtest.Options{IgnoreErrors: true}).Leveled(slog.LevelDebug)
1565 mClock = quartz.NewMock(t)
1566 updaterTickerTrap = mClock.Trap().TickerFunc("updaterLoop")
1567 mCtrl = gomock.NewController(t)
1568 mCCLI = acmock.NewMockContainerCLI(mCtrl)
1569
1570 client, db = coderdtest.NewWithDatabase(t, &coderdtest.Options{Logger: &logger})
1571 user = coderdtest.CreateFirstUser(t, client)
1572 r = dbfake.WorkspaceBuild(t, db, database.WorkspaceTable{
1573 OrganizationID: user.OrganizationID,
1574 OwnerID: user.UserID,
1575 }).WithAgent(func(agents []*proto.Agent) []*proto.Agent {
1576 return agents
1577 }).Do()
1578
1579 fakeContainer1 = codersdk.WorkspaceAgentContainer{
1580 ID: "container1",
1581 CreatedAt: dbtime.Now(),
1582 FriendlyName: "container1",
1583 Image: "busybox:latest",
1584 Labels: map[string]string{
1585 agentcontainers.DevcontainerLocalFolderLabel: "/home/coder/project1",
1586 agentcontainers.DevcontainerConfigFileLabel: "/home/coder/project1/.devcontainer/devcontainer.json",
1587 },
1588 Running: true,
1589 Status: "running",
1590 }
1591
1592 fakeContainer2 = codersdk.WorkspaceAgentContainer{
1593 ID: "container1",
1594 CreatedAt: dbtime.Now(),
1595 FriendlyName: "container2",
1596 Image: "busybox:latest",
1597 Labels: map[string]string{
1598 agentcontainers.DevcontainerLocalFolderLabel: "/home/coder/project2",
1599 agentcontainers.DevcontainerConfigFileLabel: "/home/coder/project2/.devcontainer/devcontainer.json",
1600 },
1601 Running: true,
1602 Status: "running",
1603 }
1604 )
1605
1606 stages := []struct {
1607 containers []codersdk.WorkspaceAgentContainer
1608 expected codersdk.WorkspaceAgentListContainersResponse
1609 }{
1610 {
1611 containers: []codersdk.WorkspaceAgentContainer{fakeContainer1},
1612 expected: codersdk.WorkspaceAgentListContainersResponse{
1613 Containers: []codersdk.WorkspaceAgentContainer{fakeContainer1},

Callers

nothing calls this directly

Calls 15

ContextFunction · 0.92
NewMockContainerCLIFunction · 0.92
NewWithDatabaseFunction · 0.92
CreateFirstUserFunction · 0.92
WorkspaceBuildFunction · 0.92
NowFunction · 0.92
NewFunction · 0.92
WithClockFunction · 0.92
WithContainerCLIFunction · 0.92
WithWatcherFunction · 0.92
NewNoopFunction · 0.92
NewWorkspaceAgentWaiterFunction · 0.92

Tested by

no test coverage detected