MCPcopy
hub / github.com/keploy/keploy / TestFilterByTimeStampThreeTier

Function TestFilterByTimeStampThreeTier

pkg/util_test.go:1864–1970  ·  view source on GitHub ↗

TestFilterByTimeStampThreeTier validates the Lifetime-elevated three- pool partition. Contract: - LifetimeConnection → startupMocks (connection-scoped reuse) - LifetimeSession → unfilteredMocks (session-scoped reuse) - LifetimePerTest in-window → filteredMocks - legacy meta

(t *testing.T)

Source from the content-addressed store, hash-verified

1862// - legacy no-type per-test → filteredMocks (legacy fallback path)
1863// - startup-init (req < firstWindowStart) under strict → startupMocks
1864func TestFilterByTimeStampThreeTier(t *testing.T) {
1865 if strictWindowEnvExplicitOff {
1866 t.Skip("KEPLOY_STRICT_MOCK_WINDOW=0 forces strict off — strict-tier semantics not reachable")
1867 }
1868 logger := zap.NewNop()
1869 ctx := context.Background()
1870
1871 firstWindowStart := time.Date(2026, 4, 22, 2, 0, 0, 0, time.UTC)
1872 currentStart := time.Date(2026, 4, 22, 3, 0, 0, 0, time.UTC)
1873 currentEnd := time.Date(2026, 4, 22, 3, 10, 0, 0, time.UTC)
1874
1875 // In-window PerTest → filtered.
1876 inWindow := &models.Mock{
1877 Name: "perTest-in", Version: "api.keploy.io/v1beta1",
1878 Spec: models.MockSpec{
1879 ReqTimestampMock: currentStart.Add(time.Minute),
1880 ResTimestampMock: currentStart.Add(time.Minute + time.Millisecond),
1881 },
1882 TestModeInfo: models.TestModeInfo{
1883 Lifetime: models.LifetimePerTest,
1884 LifetimeDerived: true,
1885 },
1886 }
1887 // Session → unfiltered.
1888 session := &models.Mock{
1889 Name: "session", Version: "api.keploy.io/v1beta1",
1890 Spec: models.MockSpec{
1891 ReqTimestampMock: firstWindowStart.Add(-10 * time.Minute),
1892 ResTimestampMock: firstWindowStart.Add(-10*time.Minute + time.Millisecond),
1893 },
1894 TestModeInfo: models.TestModeInfo{
1895 Lifetime: models.LifetimeSession,
1896 LifetimeDerived: true,
1897 },
1898 }
1899 // Connection → startup.
1900 conn := &models.Mock{
1901 Name: "conn", Version: "api.keploy.io/v1beta1",
1902 Spec: models.MockSpec{
1903 ReqTimestampMock: firstWindowStart.Add(-5 * time.Minute),
1904 ResTimestampMock: firstWindowStart.Add(-5*time.Minute + time.Millisecond),
1905 },
1906 TestModeInfo: models.TestModeInfo{
1907 Lifetime: models.LifetimeConnection,
1908 LifetimeDerived: true,
1909 },
1910 }
1911 // Startup-init PerTest (req < firstWindowStart) → startup.
1912 startupInit := &models.Mock{
1913 Name: "startup-init", Version: "api.keploy.io/v1beta1",
1914 Spec: models.MockSpec{
1915 ReqTimestampMock: firstWindowStart.Add(-2 * time.Minute),
1916 ResTimestampMock: firstWindowStart.Add(-2*time.Minute + time.Millisecond),
1917 },
1918 TestModeInfo: models.TestModeInfo{
1919 Lifetime: models.LifetimePerTest,
1920 LifetimeDerived: true,
1921 },

Callers

nothing calls this directly

Calls 2

AddMethod · 0.80

Tested by

no test coverage detected