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

Function TestNormalizeWorkspaceInput

codersdk/toolsdk/toolsdk_test.go:2663–2715  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2661}
2662
2663func TestNormalizeWorkspaceInput(t *testing.T) {
2664 t.Parallel()
2665
2666 testCases := []struct {
2667 name string
2668 input string
2669 expected string
2670 }{
2671 {
2672 name: "SimpleWorkspace",
2673 input: "workspace",
2674 expected: "workspace",
2675 },
2676 {
2677 name: "WorkspaceWithAgent",
2678 input: "workspace.agent",
2679 expected: "workspace.agent",
2680 },
2681 {
2682 name: "OwnerAndWorkspace",
2683 input: "owner/workspace",
2684 expected: "owner/workspace",
2685 },
2686 {
2687 name: "OwnerDashWorkspace",
2688 input: "owner--workspace",
2689 expected: "owner/workspace",
2690 },
2691 {
2692 name: "OwnerWorkspaceAgent",
2693 input: "owner/workspace.agent",
2694 expected: "owner/workspace.agent",
2695 },
2696 {
2697 name: "OwnerDashWorkspaceAgent",
2698 input: "owner--workspace.agent",
2699 expected: "owner/workspace.agent",
2700 },
2701 {
2702 name: "CoderConnectFormat",
2703 input: "agent.workspace.owner", // Special Coder Connect reverse format
2704 expected: "owner/workspace.agent",
2705 },
2706 }
2707
2708 for _, tc := range testCases {
2709 t.Run(tc.name, func(t *testing.T) {
2710 t.Parallel()
2711 result := toolsdk.NormalizeWorkspaceInput(tc.input)
2712 require.Equal(t, tc.expected, result, "Input %q should normalize to %q but got %q", tc.input, tc.expected, result)
2713 })
2714 }
2715}

Callers

nothing calls this directly

Calls 3

NormalizeWorkspaceInputFunction · 0.92
RunMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected