Skip to content

Commit e5ff236

Browse files
committed
Make GetFullyQualifiedHomeserverName easier to use in tests
Example: ``` alice.MustJoinRoom(t, bobRoomID, []string{ shardDeployment2.GetFullyQualifiedHomeserverName(t, "hs1"), }) ```
1 parent 1faf2aa commit e5ff236

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

internal/docker/deployment.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ func (hsDep *HomeserverDeployment) SetEndpoints(baseURL string, fedBaseURL strin
5757
}
5858
}
5959

60-
func (d *Deployment) GetFullyQualifiedHomeserverName(hsName string) (string, error) {
60+
func (d *Deployment) GetFullyQualifiedHomeserverName(t ct.TestLike, hsName string) string {
6161
_, ok := d.HS[hsName]
6262
if !ok {
63-
return "", fmt.Errorf("Deployment.GetFullyQualifiedHomeserverName - HS name '%s' not found", hsName)
63+
ct.Fatalf(t, "Deployment.GetFullyQualifiedHomeserverName - HS name '%s' not found", hsName)
6464
}
6565
// We have network aliases for each Docker container that will resolve the `hsName` to
6666
// the container.
67-
return hsName, nil
67+
return hsName
6868
}
6969

7070
// DestroyAtCleanup destroys the entire deployment. It should be called at cleanup time for dirty

test_package.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@ import (
2020

2121
// Deployment provides a way for tests to interact with a set of homeservers.
2222
type Deployment interface {
23-
// Returns the resolvable host name of a homeserver given its short alias (e.g.,
24-
// "hs1", "hs2").
23+
// Returns the resolvable server name (host) of a homeserver given its short alias
24+
// (e.g., "hs1", "hs2").
2525
//
2626
// In the case of the standard Docker deployment, this will be the same `hs1`, `hs2`
27-
// but may be different for other custom deployments.
28-
GetFullyQualifiedHomeserverName(hsName string) (string, error)
27+
// but may be different for other custom deployments (ex.
28+
// `shardDeployment1.GetFullyQualifiedHomeserverName(t, "hs1")` -> `hs1.shard1:8081`).
29+
GetFullyQualifiedHomeserverName(t ct.TestLike, hsName string) string
2930
// UnauthenticatedClient returns a blank CSAPI client.
3031
UnauthenticatedClient(t ct.TestLike, serverName string) *client.CSAPI
3132
// Register a new user on the given server.

0 commit comments

Comments
 (0)