Skip to content

Commit

Permalink
lint: assert.Equals -> assert.InDelta for floats
Browse files Browse the repository at this point in the history
Signed-off-by: Jake Engelberg <[email protected]>
  • Loading branch information
jake-engelberg committed Oct 11, 2024
1 parent 8293873 commit 5fd9bba
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions pkg/diagnostics/resiliency_monitoring_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,9 @@ func TestResiliencyCountMonitoringCBStates(t *testing.T) {
rowsCbState, map[tag.Tag]bool{cbTag: true, diag.NewTag(diag.PolicyKey.Name(), string(diag.CircuitBreakerPolicy)): true})
require.True(t, found)
if cbTag.Value == test.wantCbStateLastValue.Value {
require.Equal(t, float64(1), gotValue)
require.InDelta(t, float64(1), gotValue, 0)
} else {
require.Equal(t, float64(0), gotValue)
require.InDelta(t, float64(0), gotValue, 0)
}
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ func (d *defaultcircuitbreaker) Run(t *testing.T, ctx context.Context) {

// assert cb execution,activation,and current state counts
mtc := d.daprdClient.Metrics(t, context.Background())
assert.Equal(t, float64(4), mtc["dapr_resiliency_count|app_id:client|flow_direction:outbound|name:myresiliency|namespace:|policy:circuitbreaker|status:closed|target:app_server"])
assert.Equal(t, float64(0), mtc["dapr_resiliency_activations_total|app_id:client|flow_direction:outbound|name:myresiliency|namespace:|policy:circuitbreaker|status:open|target:app_server"])
assert.Equal(t, float64(1), mtc["dapr_resiliency_cb_state|app_id:client|flow_direction:outbound|name:myresiliency|namespace:|policy:circuitbreaker|status:closed|target:app_server"])
assert.InDelta(t, float64(4), mtc["dapr_resiliency_count|app_id:client|flow_direction:outbound|name:myresiliency|namespace:|policy:circuitbreaker|status:closed|target:app_server"], 0)
assert.InDelta(t, float64(0), mtc["dapr_resiliency_activations_total|app_id:client|flow_direction:outbound|name:myresiliency|namespace:|policy:circuitbreaker|status:open|target:app_server"], 0)
assert.InDelta(t, float64(1), mtc["dapr_resiliency_cb_state|app_id:client|flow_direction:outbound|name:myresiliency|namespace:|policy:circuitbreaker|status:closed|target:app_server"], 0)

// Verify the total number of calls made to the server
assert.Equal(t, int32(4), d.callCount1.Load())
Expand Down

0 comments on commit 5fd9bba

Please sign in to comment.