Skip to content

Commit

Permalink
test: fix daemon test compilation issue
Browse files Browse the repository at this point in the history
PR with commit 5f5e552 was created
before commit 6cf0df3 but the latter
commit was merged first and the first was not rebased. The former changed
data type of `Product` which was used by latter. Thus tests introduced by
latter could not be compiled.

This fix is changing the tests from the latter to use a different field
so that it doesn't need to compare slices and thus fixing the datatype issue.

Signed-off-by: Petr Vobornik <[email protected]>
  • Loading branch information
pvoborni committed Nov 23, 2023
1 parent 5f5e552 commit 6d35255
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions daemon/daemon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,13 @@ func TestRunWithLabelRefresh(t *testing.T) {
waitForStarted(t, daemon)

// Check initial labels are set to Mock default
if daemon.hostInfo.Product != "testproduct" || daemon.hostInfo.Support != "testsupport" {
if daemon.hostInfo.Usage != "testusage" || daemon.hostInfo.Support != "testsupport" {
t.Fatalf("expected initial mock labels")
}

// Change the HostInfoProvider Mock to return a predictable HostInfo after label refresh
newHostInfo := newMockHostInfoProvider(&hostinfo.HostInfo{
Product: "anotherproduct",
Usage: "anotherusage",
Support: "premium",
})

Expand All @@ -264,7 +264,7 @@ func TestRunWithLabelRefresh(t *testing.T) {
// Label refresh on label refresh interval
newHostInfo.ResetCalled()
newHostInfo.WaitForCalled(t, 1)
if daemon.hostInfo.Product != "anotherproduct" || daemon.hostInfo.Support != "premium" {
if daemon.hostInfo.Usage != "anotherusage" || daemon.hostInfo.Support != "premium" {
t.Fatalf("expected label refresh on label refresh interval, got: %s, %s", daemon.hostInfo.Product, daemon.hostInfo.Support)
}

Expand All @@ -281,19 +281,19 @@ func TestRunWithoutLabelRefresh(t *testing.T) {
waitForStarted(t, daemon)

// Check initial labels are set to Mock default
if daemon.hostInfo.Product != "testproduct" || daemon.hostInfo.Support != "testsupport" {
if daemon.hostInfo.Usage != "testusage" || daemon.hostInfo.Support != "testsupport" {
t.Fatalf("expected initial mock labels")
}

// Change the HostInfoProvider Mock to return a predictable HostInfo after label refresh
daemon.hostInfoProvider = newMockHostInfoProvider(&hostinfo.HostInfo{
Product: "anotherproduct",
Usage: "anotherusage",
Support: "premium",
})

// Wait for more than LabelRefreshInterval and check labels
time.Sleep(20 * time.Millisecond)
if daemon.hostInfo.Product != "testproduct" || daemon.hostInfo.Support != "testsupport" {
if daemon.hostInfo.Usage != "testusage" || daemon.hostInfo.Support != "testsupport" {
t.Fatalf("expected labels not to be refreshed")
}

Expand Down

0 comments on commit 6d35255

Please sign in to comment.