Skip to content

Commit

Permalink
Remove slices dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
mtoffl01 committed Feb 23, 2024
1 parent 0becfbd commit 50daa34
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions contrib/database/sql/sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"fmt"
"math"
"os"
"slices"
"strconv"
"sync"
"testing"
Expand Down Expand Up @@ -296,16 +295,32 @@ func TestOpenOptions(t *testing.T) {
time.Sleep(100 * time.Millisecond)
continue
}
if ContainsAllStats(calls) {
if containsAllStats(calls) {
break
}
t.Fatalf("Some stats missing")
}
})
}

func ContainsAllStats(calls []string) bool {
return (slices.Contains(calls, MaxOpenConnections) && slices.Contains(calls, OpenConnections) && slices.Contains(calls, InUse) && slices.Contains(calls, Idle) && slices.Contains(calls, WaitCount) && slices.Contains(calls, WaitDuration) && slices.Contains(calls, MaxIdleClosed) && slices.Contains(calls, MaxIdleTimeClosed) && slices.Contains(calls, MaxLifetimeClosed))
func containsAllStats(calls []string) bool {
wantStats := []string{MaxOpenConnections, OpenConnections, InUse, Idle, WaitCount, WaitDuration, MaxIdleClosed, MaxIdleTimeClosed, MaxLifetimeClosed}
for _, s := range wantStats {
if !contains(calls, s) {
return false
}
}
return true
}

func contains(s []string, str string) bool {
for _, v := range s {
if v == str {
return true
}
}

return false
}

func TestMySQLUint64(t *testing.T) {
Expand Down

0 comments on commit 50daa34

Please sign in to comment.