MCPcopy Create free account
hub / github.com/cli/cli / TestApp_List

Function TestApp_List

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

Source from the content-addressed store, hash-verified

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