1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
// SPDX-License-Identifier: GPL-3.0-or-later
package model_test
import (
"strings"
"testing"
"git.labunix.xyz/krino/gui/internal/model"
)
// TestAboutSaysWhatItIs: the About block names the program, the version it
// was built as, the licence, who wrote it and how to reach them.
func TestAboutSaysWhatItIs(t *testing.T) {
lines := model.About("0.0.12")
if len(lines) == 0 {
t.Fatal("About returned nothing")
}
whole := strings.Join(lines, "\n")
for _, want := range []string{
"krino",
"0.0.12",
"GPL-3.0-or-later",
"Lukasz Kasprzak",
"lukas@labunix.xyz",
"https://git.labunix.xyz/krino.git",
} {
if !strings.Contains(whole, want) {
t.Errorf("About does not mention %q:\n%s", want, whole)
}
}
if !strings.HasPrefix(lines[0], "krino ") {
t.Errorf("the first line should name the program and version, got %q", lines[0])
}
}
// TestAboutWithoutAVersion: a plain `go build` leaves "dev", and About says
// so rather than printing an empty version.
func TestAboutWithoutAVersion(t *testing.T) {
lines := model.About("")
if !strings.Contains(lines[0], "dev") {
t.Errorf("an unstamped build should read as dev, got %q", lines[0])
}
}
|