TestBuild_Success verifies that the Builder successfully creates a new Transport in both cases when provided clients.ServerIdentifer is same one of the existing transport or a new one.
(t *testing.T)
| 137 | // Transport in both cases when provided clients.ServerIdentifer is same |
| 138 | // one of the existing transport or a new one. |
| 139 | func (s) TestBuild_Success(t *testing.T) { |
| 140 | configs := map[string]Config{ |
| 141 | "local": {Credentials: &testCredentials{transportCredentials: local.NewCredentials()}}, |
| 142 | "insecure": {Credentials: insecure.NewBundle()}, |
| 143 | } |
| 144 | b := NewBuilder(configs) |
| 145 | |
| 146 | serverID1 := clients.ServerIdentifier{ |
| 147 | ServerURI: "server-address", |
| 148 | Extensions: ServerIdentifierExtension{ConfigName: "local"}, |
| 149 | } |
| 150 | tr1, err := b.Build(serverID1) |
| 151 | if err != nil { |
| 152 | t.Fatalf("Build(serverID1) call failed: %v", err) |
| 153 | } |
| 154 | defer tr1.Close() |
| 155 | |
| 156 | serverID2 := clients.ServerIdentifier{ |
| 157 | ServerURI: "server-address", |
| 158 | Extensions: ServerIdentifierExtension{ConfigName: "local"}, |
| 159 | } |
| 160 | tr2, err := b.Build(serverID2) |
| 161 | if err != nil { |
| 162 | t.Fatalf("Build(serverID2) call failed: %v", err) |
| 163 | } |
| 164 | defer tr2.Close() |
| 165 | |
| 166 | serverID3 := clients.ServerIdentifier{ |
| 167 | ServerURI: "server-address", |
| 168 | Extensions: ServerIdentifierExtension{ConfigName: "insecure"}, |
| 169 | } |
| 170 | tr3, err := b.Build(serverID3) |
| 171 | if err != nil { |
| 172 | t.Fatalf("Build(serverID3) call failed: %v", err) |
| 173 | } |
| 174 | defer tr3.Close() |
| 175 | } |
| 176 | |
| 177 | // TestBuild_Failure verifies that the Builder returns error when incorrect |
| 178 | // ServerIdentifier is provided. |
nothing calls this directly
no test coverage detected