|
|
@@ -249,3 +249,58 @@ func TestResolveEffectKeepsUnknownEffectForANameTheBoardLacks(t *testing.T) {
|
|
|
t.Errorf("error = %q, want it to stay an unknown effect", err)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+// A definition can be found and still name nothing: it refers to VIA's built-in
|
|
|
+// lighting menu, whose names are in VIA's own code and not in the file. The GMMK
|
|
|
+// Pro is one of these. Reporting an unknown effect there points at a typo in a name
|
|
|
+// the tool does not hold a single one of, and fetching again changes nothing.
|
|
|
+func TestResolveEffectSaysTheDefinitionNamesNoEffects(t *testing.T) {
|
|
|
+ catalog := NewCatalog("GMMK Pro", nil)
|
|
|
+
|
|
|
+ _, _, err := ResolveEffect(catalog, "breathing", []via.Channel{via.ChannelRgbMatrix}, true)
|
|
|
+ if err == nil {
|
|
|
+ t.Fatal("ResolveEffect() expected an error, got nil")
|
|
|
+ }
|
|
|
+ if !strings.Contains(err.Error(), "GMMK Pro") {
|
|
|
+ t.Errorf("error = %q, want it to name the board", err)
|
|
|
+ }
|
|
|
+ if strings.Contains(err.Error(), "unknown effect") {
|
|
|
+ t.Errorf("error = %q, want it not to blame the name the user typed", err)
|
|
|
+ }
|
|
|
+ if !strings.Contains(err.Error(), "effect <zone> <index>") {
|
|
|
+ t.Errorf("error = %q, want it to point at the ID form, which is all a board with no names accepts", err)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// The two ways of having no names are different and the message has to tell them
|
|
|
+// apart: one is fixed by fetching a definition, the other is not fixed by anything
|
|
|
+// the user can run.
|
|
|
+func TestResolveEffectTellsAMissingDefinitionFromOneThatNamesNothing(t *testing.T) {
|
|
|
+ _, _, missing := ResolveEffect(nil, "breathing", []via.Channel{via.ChannelRgbMatrix}, true)
|
|
|
+ _, _, empty := ResolveEffect(NewCatalog("GMMK Pro", nil), "breathing", []via.Channel{via.ChannelRgbMatrix}, true)
|
|
|
+
|
|
|
+ if missing == nil || empty == nil {
|
|
|
+ t.Fatal("both cases have to be errors")
|
|
|
+ }
|
|
|
+ if missing.Error() == empty.Error() {
|
|
|
+ t.Errorf("both messages read %q, want them told apart", empty)
|
|
|
+ }
|
|
|
+ if !strings.Contains(missing.Error(), "keyboard fetch") {
|
|
|
+ t.Errorf("missing-definition error = %q, want it to point at `keyboard fetch`", missing)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// A catalog that names one channel names effects, so the empty-catalog message must
|
|
|
+// not swallow a real lookup on that channel.
|
|
|
+func TestHasNamesIsAboutTheWholeCatalog(t *testing.T) {
|
|
|
+ var none *Catalog
|
|
|
+ if none.HasNames() {
|
|
|
+ t.Error("a nil catalog has names, want none")
|
|
|
+ }
|
|
|
+ if NewCatalog("GMMK Pro", nil).HasNames() {
|
|
|
+ t.Error("a catalog with no entries has names, want none")
|
|
|
+ }
|
|
|
+ if !impact80(t).HasNames() {
|
|
|
+ t.Error("the vendored definition has no names, want its effect list")
|
|
|
+ }
|
|
|
+}
|