Skip to content

Commit

Permalink
fix: Fix tests which were passing crunch_traffic_percent as integer i…
Browse files Browse the repository at this point in the history
…nstead of string
  • Loading branch information
tarangv committed Aug 19, 2023
1 parent 17a8518 commit 512c877
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions boltrouter/bolt_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,12 @@ func (br *BoltRouter) SelectInitialRequestTarget() (target string, reason string
return "", "", fmt.Errorf("could not cast clientBehaviorParams to map[string]interface{}")
}

crunchTrafficPercent := clientBehaviorParams["crunch_traffic_percent"]
if crunchTrafficPercent == nil {
return "", "", fmt.Errorf("could not get crunch_traffic_percent from clientBehaviorParams")
crunchTrafficPercent, ok := clientBehaviorParams["crunch_traffic_percent"].(string)
if !ok {
return "", "", fmt.Errorf("could not cast crunchTrafficPercent to string")
}

crunchTrafficPercentInt, err := strconv.Atoi(crunchTrafficPercent.(string))
crunchTrafficPercentInt, err := strconv.Atoi(crunchTrafficPercent)
if err != nil {
return "", "", fmt.Errorf("could not cast crunchTrafficPercent to int")
}
Expand Down
4 changes: 2 additions & 2 deletions boltrouter/bolt_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
func TestGetBoltInfo(t *testing.T) {
ctx := context.Background()
logger := zaptest.NewLogger(t)
SetupQuickSilverMock(t, ctx, true, map[string]interface{}{"crunch_traffic_percent": 50.0}, true, logger)
SetupQuickSilverMock(t, ctx, true, map[string]interface{}{"crunch_traffic_percent": "50.0"}, true, logger)

testCases := []struct {
name string
Expand All @@ -38,7 +38,7 @@ func TestGetBoltInfo(t *testing.T) {
func TestSelectBoltEndpoint(t *testing.T) {
ctx := context.Background()
logger := zaptest.NewLogger(t)
SetupQuickSilverMock(t, ctx, true, map[string]interface{}{"crunch_traffic_percent": 60.0}, true, logger)
SetupQuickSilverMock(t, ctx, true, map[string]interface{}{"crunch_traffic_percent": "60.0"}, true, logger)

testCases := []struct {
name string
Expand Down
6 changes: 3 additions & 3 deletions boltrouter/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ var (
failoverReadEndpoints = []interface{}{"3.0.0.1", "3.0.0.2", "3.0.0.3"}

defaultClientBehaviorParams = map[string]interface{}{
"cleaner_on": true,
"crunch_traffic_percent": 20.0,
"cleaner_on": "true",
"crunch_traffic_percent": "20.0",
}

quicksilverResponse map[string]interface{} = map[string]interface{}{
quicksilverResponse = map[string]interface{}{
"main_write_endpoints": mainWriteEndpoints,
"failover_write_endpoints": failoverWriteEndpoints,
"main_read_endpoints": mainReadEndpoints,
Expand Down

0 comments on commit 512c877

Please sign in to comment.