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

Function TestOpenApp

cli/open_test.go:630–841  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

628}
629
630func TestOpenApp(t *testing.T) {
631 t.Parallel()
632
633 t.Run("OK", func(t *testing.T) {
634 t.Parallel()
635
636 client, ws, _ := setupWorkspaceForAgent(t, func(agents []*proto.Agent) []*proto.Agent {
637 agents[0].Apps = []*proto.App{
638 {
639 Slug: "app1",
640 Url: "https://example.com/app1",
641 },
642 }
643 return agents
644 })
645
646 inv, root := clitest.New(t, "open", "app", ws.Name, "app1", "--test.open-error")
647 clitest.SetupConfig(t, client, root)
648 pty := ptytest.New(t)
649 inv.Stdin = pty.Input()
650 inv.Stdout = pty.Output()
651
652 w := clitest.StartWithWaiter(t, inv)
653 w.RequireError()
654 w.RequireContains("test.open-error")
655 })
656
657 t.Run("OnlyWorkspaceName", func(t *testing.T) {
658 t.Parallel()
659
660 client, ws, _ := setupWorkspaceForAgent(t)
661 inv, root := clitest.New(t, "open", "app", ws.Name)
662 clitest.SetupConfig(t, client, root)
663 var sb strings.Builder
664 inv.Stdout = &sb
665 inv.Stderr = &sb
666
667 w := clitest.StartWithWaiter(t, inv)
668 w.RequireSuccess()
669
670 require.Contains(t, sb.String(), "Available apps in")
671 })
672
673 t.Run("WorkspaceNotFound", func(t *testing.T) {
674 t.Parallel()
675
676 client, _, _ := setupWorkspaceForAgent(t)
677 inv, root := clitest.New(t, "open", "app", "not-a-workspace", "app1")
678 clitest.SetupConfig(t, client, root)
679 pty := ptytest.New(t)
680 inv.Stdin = pty.Input()
681 inv.Stdout = pty.Output()
682 w := clitest.StartWithWaiter(t, inv)
683 w.RequireError()
684 w.RequireContains("Resource not found or you do not have access to this resource")
685 })
686
687 t.Run("AppNotFound", func(t *testing.T) {

Callers

nothing calls this directly

Calls 15

NewFunction · 0.92
SetupConfigFunction · 0.92
NewFunction · 0.92
StartWithWaiterFunction · 0.92
NewWithDatabaseFunction · 0.92
LoggerFunction · 0.92
CreateFirstUserFunction · 0.92
WorkspaceBuildFunction · 0.92
WorkspaceSubAgentFunction · 0.92
WorkspaceAppFunction · 0.92
RequireErrorMethod · 0.80

Tested by

no test coverage detected