/
githubmirror
/
client
Обзор
Документация
Войти
/
githubmirror
/
client
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
go/engine/features_test.go
62 строки
2 KB
chrisnojima-zoom
Version 670 - clean2 (#29122)
08 июн 2026, 19:31
Не верифицирован
08 июн 2026, 19:31
1943197
Код
Авторство
О чём код?
package engine import ( "testing" "time" "github.com/keybase/client/go/libkb" "github.com/keybase/clockwork" "github.com/stretchr/testify/require" ) func TestFeatureFlagSet(t *testing.T) { tc := SetupEngineTest(t, "features") defer tc.Cleanup() fakeClock := clockwork.NewFakeClockAt(time.Now()) tc.G.SetClock(fakeClock) m := NewMetaContextForTest(tc) CreateAndSignupFakeUserPaper(tc, "feat") testFeature := libkb.Feature("test_feature") // enable the feature server side through test endpoint _, err := tc.G.API.Post(m, libkb.APIArg{ Endpoint: "test/feature", SessionType: libkb.APISessionTypeREQUIRED, Args: libkb.HTTPArgs{ "feature": libkb.S{Val: string(testFeature)}, "value": libkb.I{Val: 1}, "cache_sec": libkb.I{Val: 100}, }, }) require.NoError(t, err) // check it is on on, err := tc.G.FeatureFlags.EnabledWithError(m, testFeature) require.NoError(t, err) require.True(t, on) // turn it off server side _, err = tc.G.API.Post(m, libkb.APIArg{ Endpoint: "test/feature", SessionType: libkb.APISessionTypeREQUIRED, Args: libkb.HTTPArgs{ "feature": libkb.S{Val: string(testFeature)}, "value": libkb.I{Val: 0}, "cache_sec": libkb.I{Val: 100}, }, }) require.NoError(t, err) // Still on, since it's still cached. on, err = tc.G.FeatureFlags.EnabledWithError(m, testFeature) require.NoError(t, err) require.True(t, on) fakeClock.Advance(time.Hour * 10) for range 2 { on, err = tc.G.FeatureFlags.EnabledWithError(m, testFeature) require.NoError(t, err) require.False(t, on) } }