Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some fluky tests #351

Merged
merged 12 commits into from
Mar 23, 2022
26 changes: 14 additions & 12 deletions internal/handlers/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ func TestReadOnlyHandlers(t *testing.T) {
reqSetDB: true,
resp: types.MustNewDocument(
"ns", "monila.film",
"count", int32(1_000),
"count", int32(1_000), // FIXME
"size", int32(1_236_992),
"storageSize", int32(1_204_224),
"totalIndexSize", int32(0),
Expand All @@ -678,9 +678,9 @@ func TestReadOnlyHandlers(t *testing.T) {
db, err := req.Get("$db")
require.NoError(t, err)
if db.(string) == "monila" {
testutil.CompareAndSetByPathNum(t, expected, actual, 30_000, "size")
testutil.CompareAndSetByPathNum(t, expected, actual, 30_000, "storageSize")
testutil.CompareAndSetByPathNum(t, expected, actual, 30_000, "totalSize")
testutil.CompareAndSetByPathNum(t, expected, actual, 32_768, "size")
testutil.CompareAndSetByPathNum(t, expected, actual, 32_768, "storageSize")
testutil.CompareAndSetByPathNum(t, expected, actual, 32_768, "totalSize")
assert.Equal(t, expected, actual)
}
},
Expand Down Expand Up @@ -739,7 +739,7 @@ func TestReadOnlyHandlers(t *testing.T) {
require.NoError(t, err)
if db.(string) == "monila" {
testutil.CompareAndSetByPathNum(t, expected, actual, 50, "millis")
testutil.CompareAndSetByPathNum(t, expected, actual, 30_000, "size")
testutil.CompareAndSetByPathNum(t, expected, actual, 32_768, "size")
assert.Equal(t, expected, actual)
}
},
Expand All @@ -752,7 +752,7 @@ func TestReadOnlyHandlers(t *testing.T) {
resp: types.MustNewDocument(
"size", int32(0),
"numObjects", int32(0),
"millis", int32(20),
"millis", int32(30),
"ok", float64(1),
),
compareFunc: func(t testing.TB, req, expected, actual *types.Document) {
Expand All @@ -774,7 +774,7 @@ func TestReadOnlyHandlers(t *testing.T) {
"db", "monila",
"collections", int32(14),
"views", int32(0),
"objects", int32(30224),
"objects", int32(30_000),
"avgObjSize", 437.7342509264161,
"dataSize", 1.323008e+07,
"indexes", int32(0),
Expand All @@ -787,6 +787,7 @@ func TestReadOnlyHandlers(t *testing.T) {
db, err := req.Get("$db")
require.NoError(t, err)
if db.(string) == "monila" {
testutil.CompareAndSetByPathNum(t, expected, actual, 1_000, "objects")
testutil.CompareAndSetByPathNum(t, expected, actual, 20, "avgObjSize")
testutil.CompareAndSetByPathNum(t, expected, actual, 400_000, "dataSize")
testutil.CompareAndSetByPathNum(t, expected, actual, 400_000, "totalSize")
Expand All @@ -804,7 +805,7 @@ func TestReadOnlyHandlers(t *testing.T) {
"db", "monila",
"collections", int32(14),
"views", int32(0),
"objects", int32(30224),
"objects", int32(30_000),
"avgObjSize", 437.7342509264161,
"dataSize", 13_230.08,
"indexes", int32(0),
Expand All @@ -817,6 +818,7 @@ func TestReadOnlyHandlers(t *testing.T) {
db, err := req.Get("$db")
require.NoError(t, err)
if db.(string) == "monila" {
testutil.CompareAndSetByPathNum(t, expected, actual, 1_000, "objects")
testutil.CompareAndSetByPathNum(t, expected, actual, 20, "avgObjSize")
testutil.CompareAndSetByPathNum(t, expected, actual, 400, "dataSize")
testutil.CompareAndSetByPathNum(t, expected, actual, 400, "totalSize")
Expand Down Expand Up @@ -1069,13 +1071,13 @@ func TestListDropDatabase(t *testing.T) {
"empty", false,
),
),
"totalSize", int64(30_286_627),
"totalSizeMb", int64(28),
"totalSize", int64(30_000_000),
"totalSizeMb", int64(30),
"ok", float64(1),
)

testutil.CompareAndSetByPathNum(t, expectedList, actualList, 2_000_000, "totalSize")
testutil.CompareAndSetByPathNum(t, expectedList, actualList, 2, "totalSizeMb")
testutil.CompareAndSetByPathNum(t, expectedList, actualList, 5_000_000, "totalSize")
testutil.CompareAndSetByPathNum(t, expectedList, actualList, 5, "totalSizeMb")

expectedDBs := testutil.GetByPath(t, expectedList, "databases").(*types.Array)
actualDBs := testutil.GetByPath(t, actualList, "databases").(*types.Array)
Expand Down