Skip to content

Commit 80ca6ee

Browse files
committed
improve tests
1 parent 97094d5 commit 80ca6ee

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

t/02_daemon_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,16 @@ func daemonInit(t *testing.T, configOverride string) (bin, baseURL string, baseA
9191
}
9292

9393
// wait 10 seconds until daemon answers
94+
started := 0.0
9495
for range 200 {
95-
started := getStartedTime(t, baseURL, localDaemonPassword)
96+
started = getStartedTime(t, baseURL, localDaemonPassword)
9697
if started > 0 {
9798
break
9899
}
99100

100101
time.Sleep(50 * time.Millisecond)
101102
}
103+
require.Greaterf(t, started, 0.0, "daemon should have started and answered to http requests")
102104

103105
return bin, baseURL, baseArgs, cleanUp
104106
}

t/utils.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,12 +298,14 @@ func stopBackgroundDaemon(t *testing.T) bool {
298298
return true
299299
}
300300

301+
// returns time when daemon started, 0 if not available
301302
func getStartedTime(t *testing.T, baseURL, localDaemonPassword string) float64 {
302303
t.Helper()
303304

304305
res := runCmd(t, &cmd{
305306
Cmd: "curl",
306307
Args: []string{"-s", "-u", "user:" + localDaemonPassword, "-k", baseURL + "/api/v1/inventory/uptime"},
308+
Exit: -1,
307309
})
308310

309311
inventoryResult := struct {

0 commit comments

Comments
 (0)