|
|
@@ -111,6 +111,49 @@ func TestInfoSuccessfulRecord(t *testing.T) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+func TestInfoTextOutputIsOneLinePerChannelAndNoHeader(t *testing.T) {
|
|
|
+ t.Cleanup(vendoredDefinitions(t))
|
|
|
+ // Three channels running three different effects, which is the case a header
|
|
|
+ // could not honestly summarise: it used to print the first channel's effect
|
|
|
+ // above all of them, so `breathe` appeared twice and read as a mode the whole
|
|
|
+ // keyboard was in.
|
|
|
+ protocol := &fakeInfoProtocol{
|
|
|
+ values: map[infoKey][]byte{
|
|
|
+ {channel: 2, param: 1}: {75},
|
|
|
+ {channel: 2, param: 2}: {4},
|
|
|
+ {channel: 2, param: 3}: {1},
|
|
|
+ {channel: 2, param: 4}: {3, 255},
|
|
|
+ {channel: 3, param: 1}: {255},
|
|
|
+ {channel: 3, param: 2}: {5},
|
|
|
+ {channel: 3, param: 3}: {4},
|
|
|
+ {channel: 3, param: 4}: {3, 255},
|
|
|
+ {channel: 4, param: 1}: {160},
|
|
|
+ {channel: 4, param: 2}: {1},
|
|
|
+ {channel: 4, param: 3}: {1},
|
|
|
+ {channel: 4, param: 4}: {8, 255},
|
|
|
+ },
|
|
|
+ errors: make(map[infoKey]error),
|
|
|
+ }
|
|
|
+ t.Cleanup(stubOpenTarget(t, protocol, impact80Display(), impact80Channels(), 0x36B0, 0x309F))
|
|
|
+
|
|
|
+ var stdout bytes.Buffer
|
|
|
+ cmd := NewInfoCmd()
|
|
|
+ cmd.SetOut(&stdout)
|
|
|
+ cmd.SilenceErrors = true
|
|
|
+ cmd.SilenceUsage = true
|
|
|
+ cmd.SetArgs(nil)
|
|
|
+ if err := cmd.Execute(); err != nil {
|
|
|
+ t.Fatalf("Execute() error = %v", err)
|
|
|
+ }
|
|
|
+
|
|
|
+ want := " logo on breathe brightness 75 speed 1 color hsv:3,255\n" +
|
|
|
+ " backlight on breathing brightness 255 speed 4 color hsv:3,255\n" +
|
|
|
+ " side on wave brightness 160 speed 1 color hsv:8,255\n"
|
|
|
+ if got := stdout.String(); got != want {
|
|
|
+ t.Errorf("stdout =\n%q\nwant\n%q", got, want)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
func TestInfoErrorRecord(t *testing.T) {
|
|
|
t.Cleanup(vendoredDefinitions(t))
|
|
|
protocol := &fakeInfoProtocol{
|