Skip to content

Commit

Permalink
Fix rotate/config unit test for 32 bit yet again (#11491)
Browse files Browse the repository at this point in the history
  • Loading branch information
sgmiller committed Apr 30, 2021
1 parent d60057b commit f726f3e
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions vault/logical_system_test.go
Expand Up @@ -2066,7 +2066,7 @@ func TestSystemBackend_rotateConfig(t *testing.T) {
}

req2 := logical.TestRequest(t, logical.UpdateOperation, "rotate/config")
req2.Data["max_operations"] = int64(2345678910)
req2.Data["max_operations"] = 123456789
req2.Data["interval"] = "5432h0m0s"
req2.Data["enabled"] = false

Expand All @@ -2081,11 +2081,20 @@ func TestSystemBackend_rotateConfig(t *testing.T) {
}

exp = map[string]interface{}{
"max_operations": int64(2345678910),
"max_operations": 123456789,
"interval": "5432h0m0s",
"enabled": false,
}

// Not pretty, but on a 64-bit machine, the response value is 64-bit, while on a 32 bit machine it'll be an int
// DeepEqual rejects it due to the type difference
if d, ok := resp.Data["max_operations"]; ok {
v, ok := d.(int64)
if ok {
resp.Data["max_operations"] = int(v)
}
}

if !reflect.DeepEqual(resp.Data, exp) {
t.Fatalf("got: %#v expect: %#v", resp.Data, exp)
}
Expand Down

0 comments on commit f726f3e

Please sign in to comment.