gui tests: TestPluginPageReadsWhatItDeclared's limiter check passes on every -count round
The check called pageSetAllowed with the fixed key "x", and its last call
stored "now + 2s" in the package's limiter. The next -count round's first
call, under a second later than that, was refused, so the test was red on
every round after the first ("pageSetAllowed"). The check now uses a key
of its own run.
Run on the Linux box (wsl-run, magpie-desktop; mote and mica were at load
58 and 72), at origin/main dbaf9d68c + this change:
- go test -tags nogui -count=30 -run 'PluginPage|PageService' ./internal/gui/: ok
Broken by hand: with the old key, the same run had 27 of 30 rounds red on
this test.
Not touched: TestPluginPageServiceProxied's ubuntu CI red at 9c33839de
(the stream ended after its first event). It passed 300 rounds alone and
30 together with the plugin page tests here; filed separately.
This commit is contained in:
@@ -190,7 +190,10 @@ func TestPluginPageReadsWhatItDeclared(t *testing.T) {
|
||||
if w := post("/api/plugin-pages/options", `{"spec":`+string(offSpec)+`,"options":{"x":1}}`); w.Code == 200 {
|
||||
t.Errorf("another plugin's options set: %d", w.Code)
|
||||
}
|
||||
if !pageSetAllowed("x", time.Now()) || pageSetAllowed("x", time.Now()) || !pageSetAllowed("x", time.Now().Add(2*time.Second)) {
|
||||
// a key of this run's own: the limiter is package state, and the
|
||||
// last call leaves "now + 2s" in it for the next -count round
|
||||
key := "x" + time.Now().String()
|
||||
if !pageSetAllowed(key, time.Now()) || pageSetAllowed(key, time.Now()) || !pageSetAllowed(key, time.Now().Add(2*time.Second)) {
|
||||
t.Error("pageSetAllowed")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user