aboutsummaryrefslogtreecommitdiff
path: root/gui/internal/model
diff options
context:
space:
mode:
Diffstat (limited to 'gui/internal/model')
-rw-r--r--gui/internal/model/about.go27
-rw-r--r--gui/internal/model/about_test.go43
2 files changed, 70 insertions, 0 deletions
diff --git a/gui/internal/model/about.go b/gui/internal/model/about.go
new file mode 100644
index 0000000..e92a0f4
--- /dev/null
+++ b/gui/internal/model/about.go
@@ -0,0 +1,27 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+package model
+
+// The people and terms behind the program, in one place so About and any
+// later --about agree. The repository line joins these once there is a
+// public one to name.
+const (
+ Author = "Lukasz Kasprzak"
+ Contact = "contact@labunix.xyz"
+ Licence = "GPL-3.0-or-later"
+)
+
+// About is the block Settings shows at its foot: what this is, which build
+// it is, and under what terms. The first line names the program and its
+// version; the rest are the small print.
+func About(version string) []string {
+ if version == "" {
+ version = "dev"
+ }
+ return []string{
+ "krino " + version,
+ "A rule-based file sorter: it reads a directory, works out what belongs where, shows you the plan, and only then moves anything.",
+ "Licence: " + Licence + " - free software, with no warranty.",
+ "By " + Author + ", " + Contact,
+ }
+}
diff --git a/gui/internal/model/about_test.go b/gui/internal/model/about_test.go
new file mode 100644
index 0000000..00a6718
--- /dev/null
+++ b/gui/internal/model/about_test.go
@@ -0,0 +1,43 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+package model_test
+
+import (
+ "strings"
+ "testing"
+
+ "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",
+ "contact@labunix.xyz",
+ } {
+ 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])
+ }
+}