Merge pull request 'Revert power's bar item attributes, which every node-engine refuses, so machines compose again (issue 774)' (#566) from fix/power-item-attributes into main
Reviewed-on: #566
This commit was merged in pull request #566.
This commit is contained in:
@@ -84,9 +84,7 @@ func TestEveryFileTakesItsTextFromATemplateOutsideTheUnpackedFiles(t *testing.T)
|
|||||||
|
|
||||||
// The bar's blocks are two items of the collection the bar places (design 57 L3, issue 781): the text i3status-rust's
|
// The bar's blocks are two items of the collection the bar places (design 57 L3, issue 781): the text i3status-rust's
|
||||||
// bars hold for the battery and for the power draw, byte for byte as the bar's own template rendered them before, the
|
// bars hold for the battery and for the power draw, byte for byte as the bar's own template rendered them before, the
|
||||||
// draw's key being the machine's own name. The draw's item says the state its text reads (shows: state, state:
|
// draw's key being the machine's own name.
|
||||||
// power.draw), as the bar's contribution said it before, so the bar's holder is granted this machine's key of it (the
|
|
||||||
// sweep of 2026-10-30, issue 774: moved to an item, it said nothing, and i3status-rust was issued no read).
|
|
||||||
func TestTheBarBlocksAreTwoItemsOfTheBarsCollection(t *testing.T) {
|
func TestTheBarBlocksAreTwoItemsOfTheBarsCollection(t *testing.T) {
|
||||||
raw, err := os.ReadFile("../../module.json")
|
raw, err := os.ReadFile("../../module.json")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -108,20 +106,19 @@ func TestTheBarBlocksAreTwoItemsOfTheBarsCollection(t *testing.T) {
|
|||||||
if len(m.Contributions) != 0 || len(m.Items) != 2 {
|
if len(m.Contributions) != 0 || len(m.Items) != 2 {
|
||||||
t.Fatalf("%d contributions and %d items", len(m.Contributions), len(m.Items))
|
t.Fatalf("%d contributions and %d items", len(m.Contributions), len(m.Items))
|
||||||
}
|
}
|
||||||
want := []struct{ name, capability, order, reads, template, text string }{
|
want := []struct{ name, capability, order, template, text string }{
|
||||||
{"battery", "battery", "40", "", "templates/bar-battery", "[[block]]\nblock = \"battery\"\n" +
|
{"battery", "battery", "40", "templates/bar-battery", "[[block]]\nblock = \"battery\"\n" +
|
||||||
"format = \"$icon $percentage{ $time|}\"\ncharging_format = \"$icon $percentage{ $time|}\"\n" +
|
"format = \"$icon $percentage{ $time|}\"\ncharging_format = \"$icon $percentage{ $time|}\"\n" +
|
||||||
"not_charging_format = \"$icon $percentage\"\nfull_format = \"$icon $percentage\"\n" +
|
"not_charging_format = \"$icon $percentage\"\nfull_format = \"$icon $percentage\"\n" +
|
||||||
"empty_format = \"$icon $percentage\"\nmissing_format = \"\"\n\n"},
|
"empty_format = \"$icon $percentage\"\nmissing_format = \"\"\n\n"},
|
||||||
{"power-draw", "power-meter", "45", "power.draw", "templates/bar-power-draw", "[[block]]\nblock = \"custom\"\n" +
|
{"power-draw", "power-meter", "45", "templates/bar-power-draw", "[[block]]\nblock = \"custom\"\n" +
|
||||||
"command = \"~/.local/bin/i3status-value power.draw ${machine:name}\"\ninterval = 5\nhide_when_empty = true\n\n"},
|
"command = \"~/.local/bin/i3status-value power.draw ${machine:name}\"\ninterval = 5\nhide_when_empty = true\n\n"},
|
||||||
}
|
}
|
||||||
for i, w := range want {
|
for i, w := range want {
|
||||||
it := m.Items[i]
|
it := m.Items[i]
|
||||||
if it.Collection != "contribution:node-bar:block" || it.Name != w.name || it.IfCapability != w.capability ||
|
if it.Collection != "contribution:node-bar:block" || it.Name != w.name || it.IfCapability != w.capability ||
|
||||||
it.Template != w.template || it.Attributes["bar"] != "bottom" || it.Attributes["place"] != "status" ||
|
it.Template != w.template || it.Attributes["bar"] != "bottom" || it.Attributes["place"] != "status" ||
|
||||||
it.Attributes["order"] != w.order || it.Attributes["state"] != w.reads ||
|
it.Attributes["order"] != w.order || len(it.Attributes) != 3 {
|
||||||
(w.reads != "") != (it.Attributes["shows"] == "state") || len(it.Attributes) != map[bool]int{false: 3, true: 5}[w.reads != ""] {
|
|
||||||
t.Errorf("item %d is %+v", i, it)
|
t.Errorf("item %d is %+v", i, it)
|
||||||
}
|
}
|
||||||
text, err := os.ReadFile(filepath.Join("../..", w.template))
|
text, err := os.ReadFile(filepath.Join("../..", w.template))
|
||||||
|
|||||||
@@ -442,9 +442,7 @@
|
|||||||
"attributes": {
|
"attributes": {
|
||||||
"bar": "bottom",
|
"bar": "bottom",
|
||||||
"place": "status",
|
"place": "status",
|
||||||
"order": "45",
|
"order": "45"
|
||||||
"shows": "state",
|
|
||||||
"state": "power.draw"
|
|
||||||
},
|
},
|
||||||
"template": "templates/bar-power-draw"
|
"template": "templates/bar-power-draw"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user