Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions cmd/screens/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@ func run() error {
return err
}
// One file a screen: a test that is retried starts a new worker, which would lose what an
// earlier test had gathered in memory.
var a audit
// earlier test had gathered in memory. An audit with nothing found is an empty list, not null:
// screens.html reads it as an array.
a := audit{Findings: []finding{}}
audits, err := filepath.Glob(filepath.Join(*from, "*.audit.json"))
if err != nil {
return err
Expand Down Expand Up @@ -212,6 +213,9 @@ func whole(screens []screen, images []string, a audit) error {
errs = append(errs, fmt.Errorf("%s was not taken", w))
}
}
if a.Findings == nil {
errs = append(errs, errors.New("the audit's findings are null, not a list: screens.html reads an array"))
}
for _, f := range a.Findings {
if !names[f.Screen] || !slices.Contains(themes, f.Theme) || !slices.Contains(widths, f.Width) {
errs = append(errs, fmt.Errorf("a finding about %s.%s.%s, which the catalog does not have", f.Screen, f.Theme, f.Width))
Expand Down
8 changes: 8 additions & 0 deletions cmd/screens/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,18 @@ func TestWholeRefusesACatalogWithAGap(t *testing.T) {
screens []screen
images []string
audit audit
null bool
refused string
}{
{name: "every theme at every width", screens: []screen{workspaces}, images: all},
{name: "a width not taken", screens: []screen{workspaces}, images: all[1:], refused: "workspaces.dark.desktop.png was not taken"},
{name: "an image of no screen", screens: []screen{workspaces}, images: append(all, "gone.light.desktop.png"), refused: "gone.light.desktop.png is no screen"},
{name: "a kind that is neither", screens: []screen{{Name: "workspaces", Kind: "drawer"}}, images: all, refused: `"drawer", not a page or a dialog`},
{name: "one name twice", screens: []screen{workspaces, workspaces}, images: all, refused: "two screens are named workspaces"},
{
name: "findings that are null", screens: []screen{workspaces}, images: all, null: true,
refused: "the audit's findings are null",
},
{
name: "a finding about no screen", screens: []screen{workspaces}, images: all,
audit: audit{Findings: []finding{{Screen: "gone", Theme: "dark", Width: "desktop"}}},
Expand All @@ -36,6 +41,9 @@ func TestWholeRefusesACatalogWithAGap(t *testing.T) {
}
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
if c.audit.Findings == nil && !c.null {
c.audit.Findings = []finding{}
}
err := whole(c.screens, c.images, c.audit)
if c.refused == "" {
if err != nil {
Expand Down
Loading
Loading