34 lines
1.4 KiB
Go
34 lines
1.4 KiB
Go
package main
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
// ADR 0501 §6, §7 (issue 1851, A5b): the condition of a new module reads its key's take-in: one waiting for a controller
|
|
// that reads its manifest's word is named at once, one waiting for its key only past the bound, each reason said once.
|
|
func TestANewModuleWaitingIsNamedByWhatItWaitsFor(t *testing.T) {
|
|
t.Cleanup(func() {
|
|
newModulesWaiting.Lock()
|
|
newModulesWaiting.by = map[string]newModuleWait{}
|
|
newModulesWaiting.Unlock()
|
|
})
|
|
word := `waits: watchman's manifest uses the word "key-ttl", which this controller does not read: it is registered when a controller that reads it runs`
|
|
sayNewModuleWait(newModuleWait{Module: "watchman", Commit: "c1", Why: word, Word: wordIn(word)})
|
|
sayNewModuleWait(newModuleWait{Module: "view", Commit: "c1", Why: "waits: the build of view at aaaa is building on ace"})
|
|
now := time.Now()
|
|
obs := newModuleObservations(now)
|
|
if len(obs) != 1 || !strings.Contains(obs[0].Summary, `"key-ttl"`) || obs[0].Kind != kindNewModuleWaits {
|
|
t.Fatalf("at once, only the unread word is named: %+v", obs)
|
|
}
|
|
if obs := newModuleObservations(now.Add(newModuleWaitBound + time.Minute)); len(obs) != 2 {
|
|
t.Fatalf("past the bound, both are named: %+v", obs)
|
|
}
|
|
forgetNewModuleWait("watchman")
|
|
forgetNewModuleWait("view")
|
|
if obs := newModuleObservations(now.Add(time.Hour)); len(obs) != 0 {
|
|
t.Fatalf("registered modules are still named: %+v", obs)
|
|
}
|
|
}
|