-
Notifications
You must be signed in to change notification settings - Fork 10
/
store_sync_failure_log_test.go
49 lines (45 loc) · 1.15 KB
/
store_sync_failure_log_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//go:build !race
// +build !race
package statsig
import (
"net/http"
"net/http/httptest"
"strings"
"testing"
"time"
)
func TestStoreSyncFailure(t *testing.T) {
testServer := httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
if strings.Contains(req.URL.Path, "/download_config_specs") {
res.WriteHeader(500)
return
}
}))
defer testServer.Close()
opt := &Options{
API: testServer.URL,
Environment: Environment{Tier: "test"},
ConfigSyncInterval: 100 * time.Millisecond,
OutputLoggerOptions: getOutputLoggerOptionsForTest(t),
StatsigLoggerOptions: getStatsigLoggerOptionsForTest(t),
}
syncOutdatedMax = 200 * time.Millisecond
stderrLogs := swallow_stderr(func() {
InitializeWithOptions("secret-key", opt)
})
if stderrLogs == "" {
t.Error("Expected error message in stderr")
}
stderrLogs = swallow_stderr(func() {
time.Sleep(100 * time.Millisecond)
})
if stderrLogs != "" {
t.Error("Expected no output to stderr")
}
stderrLogs = swallow_stderr(func() {
time.Sleep(100 * time.Millisecond)
})
if stderrLogs == "" {
t.Error("Expected error message in stderr")
}
}