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

Function fakeContainer

agent/agentcontainers/api_test.go:4257–4284  ·  view source on GitHub ↗
(t *testing.T, mut ...func(*codersdk.WorkspaceAgentContainer))

Source from the content-addressed store, hash-verified

4255}
4256
4257func fakeContainer(t *testing.T, mut ...func(*codersdk.WorkspaceAgentContainer)) codersdk.WorkspaceAgentContainer {
4258 t.Helper()
4259 ct := codersdk.WorkspaceAgentContainer{
4260 CreatedAt: time.Now().UTC(),
4261 ID: uuid.New().String(),
4262 FriendlyName: testutil.GetRandomName(t),
4263 Image: testutil.GetRandomName(t) + ":" + strings.Split(uuid.New().String(), "-")[0],
4264 Labels: map[string]string{
4265 testutil.GetRandomName(t): testutil.GetRandomName(t),
4266 },
4267 Running: true,
4268 Ports: []codersdk.WorkspaceAgentContainerPort{
4269 {
4270 Network: "tcp",
4271 Port: testutil.RandomPortNoListen(t),
4272 HostPort: testutil.RandomPortNoListen(t),
4273 //nolint:gosec // this is a test
4274 HostIP: []string{"127.0.0.1", "[::1]", "localhost", "0.0.0.0", "[::]", testutil.GetRandomName(t)}[rand.Intn(6)],
4275 },
4276 },
4277 Status: testutil.MustRandString(t, 10),
4278 Volumes: map[string]string{testutil.GetRandomName(t): testutil.GetRandomName(t)},
4279 }
4280 for _, m := range mut {
4281 m(&ct)
4282 }
4283 return ct
4284}
4285
4286func TestWithDevcontainersNameGeneration(t *testing.T) {
4287 t.Parallel()

Callers 2

TestAPIFunction · 0.85

Calls 6

GetRandomNameFunction · 0.92
RandomPortNoListenFunction · 0.92
MustRandStringFunction · 0.92
HelperMethod · 0.65
NewMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected