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") } }