(t *testing.T)
| 47 | } |
| 48 | |
| 49 | func TestFetchCodespaces(t *testing.T) { |
| 50 | var ( |
| 51 | octocatOwner = api.RepositoryOwner{Login: "octocat"} |
| 52 | cliOwner = api.RepositoryOwner{Login: "cli"} |
| 53 | octocatA = &api.Codespace{ |
| 54 | Name: "1", |
| 55 | Repository: api.Repository{FullName: "octocat/A", Owner: octocatOwner}, |
| 56 | } |
| 57 | |
| 58 | octocatA2 = &api.Codespace{ |
| 59 | Name: "2", |
| 60 | Repository: api.Repository{FullName: "octocat/A", Owner: octocatOwner}, |
| 61 | } |
| 62 | |
| 63 | cliA = &api.Codespace{ |
| 64 | Name: "3", |
| 65 | Repository: api.Repository{FullName: "cli/A", Owner: cliOwner}, |
| 66 | } |
| 67 | |
| 68 | octocatB = &api.Codespace{ |
| 69 | Name: "4", |
| 70 | Repository: api.Repository{FullName: "octocat/B", Owner: octocatOwner}, |
| 71 | } |
| 72 | ) |
| 73 | |
| 74 | tests := []struct { |
| 75 | tName string |
| 76 | apiCodespaces []*api.Codespace |
| 77 | codespaceName string |
| 78 | repoName string |
| 79 | repoOwner string |
| 80 | wantCodespaces []*api.Codespace |
| 81 | wantErr error |
| 82 | }{ |
| 83 | // Empty case |
| 84 | { |
| 85 | tName: "empty", |
| 86 | apiCodespaces: nil, |
| 87 | wantCodespaces: nil, |
| 88 | wantErr: errNoCodespaces, |
| 89 | }, |
| 90 | |
| 91 | // Tests with no filtering |
| 92 | { |
| 93 | tName: "no filtering, single codespaces", |
| 94 | apiCodespaces: []*api.Codespace{octocatA}, |
| 95 | wantCodespaces: []*api.Codespace{octocatA}, |
| 96 | wantErr: nil, |
| 97 | }, |
| 98 | { |
| 99 | tName: "no filtering, multiple codespace", |
| 100 | apiCodespaces: []*api.Codespace{octocatA, cliA, octocatB}, |
| 101 | wantCodespaces: []*api.Codespace{octocatA, cliA, octocatB}, |
| 102 | }, |
| 103 | |
| 104 | // Test repo filtering |
| 105 | { |
| 106 | tName: "repo name filtering, single codespace", |
nothing calls this directly
no test coverage detected