(t *testing.T)
| 149 | } |
| 150 | |
| 151 | func TestReposRun(t *testing.T) { |
| 152 | var now = time.Date(2022, 2, 28, 12, 30, 0, 0, time.UTC) |
| 153 | var updatedAt = time.Date(2021, 2, 28, 12, 30, 0, 0, time.UTC) |
| 154 | var query = search.Query{ |
| 155 | Keywords: []string{"cli"}, |
| 156 | Kind: "repositories", |
| 157 | Limit: 30, |
| 158 | Qualifiers: search.Qualifiers{ |
| 159 | Stars: ">50", |
| 160 | Topic: []string{"golang"}, |
| 161 | }, |
| 162 | } |
| 163 | tests := []struct { |
| 164 | errMsg string |
| 165 | name string |
| 166 | opts *ReposOptions |
| 167 | tty bool |
| 168 | wantErr bool |
| 169 | wantStderr string |
| 170 | wantStdout string |
| 171 | }{ |
| 172 | { |
| 173 | name: "displays results tty", |
| 174 | opts: &ReposOptions{ |
| 175 | Query: query, |
| 176 | Searcher: &search.SearcherMock{ |
| 177 | RepositoriesFunc: func(query search.Query) (search.RepositoriesResult, error) { |
| 178 | return search.RepositoriesResult{ |
| 179 | IncompleteResults: false, |
| 180 | Items: []search.Repository{ |
| 181 | {FullName: "test/cli", Description: "of course", IsPrivate: true, IsArchived: true, UpdatedAt: updatedAt, Visibility: "private"}, |
| 182 | {FullName: "test/cliing", Description: "wow", IsFork: true, UpdatedAt: updatedAt, Visibility: "public"}, |
| 183 | {FullName: "cli/cli", Description: "so much", IsArchived: false, UpdatedAt: updatedAt, Visibility: "internal"}, |
| 184 | }, |
| 185 | Total: 300, |
| 186 | }, nil |
| 187 | }, |
| 188 | }, |
| 189 | }, |
| 190 | tty: true, |
| 191 | wantStdout: "\nShowing 3 of 300 repositories\n\nNAME DESCRIPTION VISIBILITY UPDATED\ntest/cli of course private, archived about 1 year ago\ntest/cliing wow public, fork about 1 year ago\ncli/cli so much internal about 1 year ago\n", |
| 192 | }, |
| 193 | { |
| 194 | name: "displays results notty", |
| 195 | opts: &ReposOptions{ |
| 196 | Query: query, |
| 197 | Searcher: &search.SearcherMock{ |
| 198 | RepositoriesFunc: func(query search.Query) (search.RepositoriesResult, error) { |
| 199 | return search.RepositoriesResult{ |
| 200 | IncompleteResults: false, |
| 201 | Items: []search.Repository{ |
| 202 | {FullName: "test/cli", Description: "of course", IsPrivate: true, IsArchived: true, UpdatedAt: updatedAt, Visibility: "private"}, |
| 203 | {FullName: "test/cliing", Description: "wow", IsFork: true, UpdatedAt: updatedAt, Visibility: "public"}, |
| 204 | {FullName: "cli/cli", Description: "so much", IsArchived: false, UpdatedAt: updatedAt, Visibility: "internal"}, |
| 205 | }, |
| 206 | Total: 300, |
| 207 | }, nil |
| 208 | }, |
nothing calls this directly
no test coverage detected