42c7b8b927
Config gains an intake flag, off by default, and sendMessageReq gains the inline keyboard the intake half hangs under a reply. The gesture itself is the web's, ported: one button says the turn was wrong, and it opens the seven intents rather than writing the negative straight away, because the target is worth much more and he must still be able to decline naming one. Button data comes off the wire, so parseCallback refuses an id it cannot parse and a target that is not one of the seven. A label nothing can score is worse than no label.
31 lines
1.1 KiB
Go
31 lines
1.1 KiB
Go
package telegramsink
|
|
|
|
import "testing"
|
|
|
|
// Button data comes off the wire. An unparseable id or an intent that is not one
|
|
// of the seven must not reach the label table V-632 fits prototypes from.
|
|
func TestParseCallbackRejectsWhatCannotBeALabel(t *testing.T) {
|
|
for _, data := range []string{
|
|
"", "nonsense", "w:", "w:0", "w:-3", "w:abc",
|
|
"t:77", "t:0:note", "t:abc:note", "t:77:погода", "t:77:fact:extra",
|
|
} {
|
|
if _, _, kind := parseCallback(data); kind != callbackUnknown {
|
|
t.Errorf("%q was accepted, want callbackUnknown", data)
|
|
}
|
|
}
|
|
if id, target, kind := parseCallback("t:77:reminder"); id != 77 || target != "reminder" || kind != callbackTarget {
|
|
t.Errorf("got %d %q %v, want the reminder correction", id, target, kind)
|
|
}
|
|
}
|
|
|
|
// Every intent the web offers has a button here, so a new intent cannot exist
|
|
// with no way to correct a chat turn into it.
|
|
func TestIntakeTargetsAreTheSeven(t *testing.T) {
|
|
if len(CorrectionTargets) != 7 {
|
|
t.Fatalf("%d targets, want the seven public intents", len(CorrectionTargets))
|
|
}
|
|
if isCorrectionTarget("") {
|
|
t.Error("empty is the absence of a target, not one of them")
|
|
}
|
|
}
|