Skip to content

Commit 08b2d36

Browse files
committed
clean up unused variables
1 parent 1187918 commit 08b2d36

1 file changed

Lines changed: 21 additions & 16 deletions

File tree

integration-test/integration_test.go

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
const attempts = 20
2222

2323
func TestMain(m *testing.M) {
24-
host, healthPath, basePath := grabTestHost()
24+
host, _, _ := grabTestHost()
2525

2626
err := healthCheck(attempts)
2727
if err != nil {
@@ -36,7 +36,7 @@ func TestMain(m *testing.M) {
3636

3737
func healthCheck(attempts int) error {
3838
var err error
39-
host, healthPath, basePath := grabTestHost()
39+
_, healthPath, _ := grabTestHost()
4040

4141
for attempts > 0 {
4242
err = Do(Get(healthPath), Expect().Status().Equal(http.StatusOK))
@@ -55,7 +55,7 @@ func healthCheck(attempts int) error {
5555
}
5656

5757
func TestWebFooterVersion(t *testing.T) {
58-
host, healthPath, basePath := grabTestHost()
58+
_, _, basePath := grabTestHost()
5959

6060
Test(t,
6161
Description("Footer Version"),
@@ -69,7 +69,7 @@ func TestWebFooterVersion(t *testing.T) {
6969
// New tests based on controller/web
7070
// login/page
7171
func TestWebAuthUser(t *testing.T) {
72-
host, healthPath, basePath := grabTestHost()
72+
_, _, basePath := grabTestHost()
7373
username, password := grabTestUser()
7474

7575
Test(t,
@@ -114,7 +114,7 @@ func TestWebAuthUser(t *testing.T) {
114114
// devices
115115
func TestWebDevice(t *testing.T) {
116116
client, loginSteps := webAuthSteps()
117-
host, healthPath, basePath := grabTestHost()
117+
_, _, basePath := grabTestHost()
118118

119119
Test(t,
120120
Description("Login for Device"),
@@ -177,7 +177,7 @@ func TestHTTPKoreaderSyncProgress(t *testing.T) {
177177
deviceName := generateDeviceName()
178178
deviceSteps := setupDeviceSteps(client, deviceName)
179179
Test(t, Description("Device Register"), deviceSteps)
180-
host, healthPath, basePath := grabTestHost()
180+
_, _, basePath := grabTestHost()
181181

182182
// check auth
183183
Test(t,
@@ -218,7 +218,7 @@ func TestHTTPKoreaderSyncProgress(t *testing.T) {
218218
// HTTP GET /users/auth
219219
func TestHTTPAuth(t *testing.T) {
220220
username, password := grabTestUser()
221-
host, healthPath, basePath := grabTestHost()
221+
_, _, basePath := grabTestHost()
222222
Test(t,
223223
Description("Auth With Incorrect Password"),
224224
Get(basePath+"/users/auth"),
@@ -276,7 +276,7 @@ func TestHTTPKompanionShelf(t *testing.T) {
276276

277277
client, loginSteps := webAuthSteps()
278278
Test(t, Description("Login for Device"), loginSteps)
279-
host, healthPath, basePath := grabTestHost()
279+
_, _, basePath := grabTestHost()
280280

281281
// put book
282282
var redirectedPath string
@@ -355,7 +355,7 @@ func TestWebStats(t *testing.T) {
355355
Test(t, Description("Device Register"), deviceSteps)
356356

357357
basicAuth := "Basic " + base64.StdEncoding.EncodeToString([]byte(deviceName+":"+password))
358-
host, healthPath, basePath := grabTestHost()
358+
_, _, basePath := grabTestHost()
359359

360360
statsContent, err := os.ReadFile("../test/test_data/koreader/koreader_statistics_example.sqlite3")
361361
if err != nil {
@@ -423,7 +423,7 @@ func TestHTTPKompanionOPDS(t *testing.T) {
423423

424424
client, loginSteps := webAuthSteps()
425425
Test(t, Description("Login for Device"), loginSteps)
426-
host, healthPath, basePath := grabTestHost()
426+
_, _, basePath := grabTestHost()
427427

428428
// put book
429429
var redirectedPath string
@@ -465,8 +465,13 @@ func TestHTTPKompanionOPDS(t *testing.T) {
465465
// seach opds
466466
}
467467

468+
func readPrefixedEnv(key string) string {
469+
envKey := fmt.Sprintf("KOMPANION_%s", strings.ToUpper(key))
470+
return os.Getenv(envKey)
471+
}
472+
468473
func grabTestHost() (host string, healthPath string, basePath string) {
469-
host := readPrefixedEnv("TEST_HOST")
474+
host = readPrefixedEnv("TEST_HOST")
470475

471476
if host == "" {
472477
host = "app:8080"
@@ -478,9 +483,9 @@ func grabTestHost() (host string, healthPath string, basePath string) {
478483
return host, healthPath, basePath
479484
}
480485

481-
func grabTestUser() (string, string) {
482-
user := readPrefixedEnv("TEST_USER")
483-
password := readPrefixedEnv("TEST_PASSWORD")
486+
func grabTestUser() (user string, password string) {
487+
user = readPrefixedEnv("TEST_USER")
488+
password = readPrefixedEnv("TEST_PASSWORD")
484489

485490
if user == "" || password == "" {
486491
user = "user"
@@ -501,7 +506,7 @@ func hashSyncPassword(password string) string {
501506

502507
// webAuthSteps returns a client and a step to authenticate
503508
func webAuthSteps() (*http.Client, hit.IStep) {
504-
host := readPrefixedEnv("HEALTHCHECK_HOST")
509+
_, _, basePath := grabTestHost()
505510
username, password := grabTestUser()
506511

507512
jar, err := cookiejar.New(nil)
@@ -530,7 +535,7 @@ func webAuthSteps() (*http.Client, hit.IStep) {
530535
}
531536

532537
func setupDeviceSteps(client *http.Client, deviceName string) hit.IStep {
533-
host := readPrefixedEnv("HEALTHCHECK_HOST")
538+
_, _, basePath := grabTestHost()
534539
return CombineSteps(
535540
HTTPClient(client),
536541
Description("Device Register"),

0 commit comments

Comments
 (0)