(t *testing.T)
| 120 | } |
| 121 | |
| 122 | func TestGitRemoteURL(t *testing.T) { |
| 123 | ctx := context.TODO() |
| 124 | type remote struct { |
| 125 | name string |
| 126 | url string |
| 127 | tracking string |
| 128 | } |
| 129 | |
| 130 | cases := []struct { |
| 131 | name string |
| 132 | remotes []remote |
| 133 | expected string |
| 134 | fail bool |
| 135 | }{ |
| 136 | { |
| 137 | name: "no remotes", |
| 138 | remotes: []remote{}, |
| 139 | fail: true, |
| 140 | }, |
| 141 | { |
| 142 | name: "origin", |
| 143 | remotes: []remote{ |
| 144 | { |
| 145 | name: "origin", |
| 146 | url: "git@github.com:crazy-max/buildx.git", |
| 147 | }, |
| 148 | }, |
| 149 | expected: "git@github.com:crazy-max/buildx.git", |
| 150 | }, |
| 151 | { |
| 152 | name: "upstream", |
| 153 | remotes: []remote{ |
| 154 | { |
| 155 | name: "upstream", |
| 156 | url: "git@github.com:docker/buildx.git", |
| 157 | }, |
| 158 | }, |
| 159 | expected: "git@github.com:docker/buildx.git", |
| 160 | }, |
| 161 | { |
| 162 | name: "origin and upstream", |
| 163 | remotes: []remote{ |
| 164 | { |
| 165 | name: "upstream", |
| 166 | url: "git@github.com:docker/buildx.git", |
| 167 | }, |
| 168 | { |
| 169 | name: "origin", |
| 170 | url: "git@github.com:crazy-max/buildx.git", |
| 171 | }, |
| 172 | }, |
| 173 | expected: "git@github.com:crazy-max/buildx.git", |
| 174 | }, |
| 175 | { |
| 176 | name: "not found", |
| 177 | remotes: []remote{ |
| 178 | { |
| 179 | name: "foo", |
nothing calls this directly
no test coverage detected
searching dependent graphs…