MCPcopy Index your code
hub / github.com/cli/cli / TestApp_List

Function TestApp_List

pkg/cmd/codespace/list_test.go:66–277  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

64}
65
66func TestApp_List(t *testing.T) {
67 type fields struct {
68 apiClient apiClient
69 }
70 tests := []struct {
71 name string
72 fields fields
73 opts *listOptions
74 wantError error
75 wantURL string
76 }{
77 {
78 name: "list codespaces, no flags",
79 fields: fields{
80 apiClient: &apiClientMock{
81 ListCodespacesFunc: func(ctx context.Context, opts api.ListCodespacesOptions) ([]*api.Codespace, error) {
82 if opts.OrgName != "" {
83 return nil, fmt.Errorf("should not be called with an orgName")
84 }
85 return []*api.Codespace{
86 {
87 DisplayName: "CS1",
88 CreatedAt: "2023-01-01T00:00:00Z",
89 },
90 }, nil
91 },
92 },
93 },
94 opts: &listOptions{},
95 },
96 {
97 name: "list codespaces, --org flag",
98 fields: fields{
99 apiClient: &apiClientMock{
100 ListCodespacesFunc: func(ctx context.Context, opts api.ListCodespacesOptions) ([]*api.Codespace, error) {
101 if opts.OrgName != "TestOrg" {
102 return nil, fmt.Errorf("Expected orgName to be TestOrg. Got %s", opts.OrgName)
103 }
104 if opts.UserName != "" {
105 return nil, fmt.Errorf("Expected userName to be blank. Got %s", opts.UserName)
106 }
107 return []*api.Codespace{
108 {
109 DisplayName: "CS1",
110 CreatedAt: "2023-01-01T00:00:00Z",
111 },
112 }, nil
113 },
114 },
115 },
116 opts: &listOptions{
117 orgName: "TestOrg",
118 },
119 },
120 {
121 name: "list codespaces, --org and --user flag",
122 fields: fields{
123 apiClient: &apiClientMock{

Callers

nothing calls this directly

Calls 6

ListMethod · 0.95
VerifyMethod · 0.95
TestFunction · 0.92
ErrorfMethod · 0.65
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected