MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / TestCompactIntervalFromConfig

Function TestCompactIntervalFromConfig

rest/server_context_test.go:865–908  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

863}
864
865func TestCompactIntervalFromConfig(t *testing.T) {
866 testCases := []struct {
867 name string
868 compactIntervalDays *float32
869 expectedCompactIntervalSecs uint32
870 }{
871 {
872 name: "compact interval days not set",
873 compactIntervalDays: nil,
874 expectedCompactIntervalSecs: uint32(db.DefaultCompactInterval.Seconds()),
875 },
876 {
877 name: "explicit 1",
878 compactIntervalDays: base.Ptr(float32(1)),
879 expectedCompactIntervalSecs: uint32((24 * time.Hour).Seconds()),
880 },
881 {
882 name: "1.5",
883 compactIntervalDays: base.Ptr(float32(1.5)),
884 expectedCompactIntervalSecs: uint32((1.5 * 24 * time.Hour).Seconds()),
885 },
886 {
887 name: "2",
888 compactIntervalDays: base.Ptr(float32(2)),
889 expectedCompactIntervalSecs: uint32((2 * 24 * time.Hour).Seconds()),
890 },
891 }
892 for _, test := range testCases {
893 t.Run(test.name, func(t *testing.T) {
894
895 ctx := base.TestCtx(t)
896 startupConfig := &StartupConfig{}
897 sc := NewServerContext(ctx, startupConfig, false)
898 defer sc.Close(ctx)
899 config := &DbConfig{
900 CompactIntervalDays: test.compactIntervalDays,
901 Unsupported: &db.UnsupportedOptions{},
902 }
903 opts, err := dbcOptionsFromConfig(base.TestCtx(t), sc, config, "fakedb")
904 require.NoError(t, err)
905 require.Equal(t, int(test.expectedCompactIntervalSecs), int(opts.CompactInterval))
906 })
907 }
908}
909
910func TestHeapProfileValuesPopulated(t *testing.T) {
911 totalMemory := uint64(float64(getTotalMemory(base.TestCtx(t))) * 0.85)

Callers

nothing calls this directly

Calls 7

CloseMethod · 0.95
PtrFunction · 0.92
TestCtxFunction · 0.92
NewServerContextFunction · 0.85
dbcOptionsFromConfigFunction · 0.85
RunMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected