Files

64 lines
2.1 KiB
Go

// Cthulhu screen reader.
// Copyright (c) 2026 Storm Dragon
// Authors: Storm Dragon, Angus Kola
//
// This program is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the Free
// Software Foundation, either version 3 of the License, or (at your option)
// any later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
// more details.
//
// You should have received a copy of the GNU General Public License along with
// this program. If not, see <https://www.gnu.org/licenses/gpl-3.0.html>.
package version
import (
"strings"
"testing"
)
func TestStringIncludesBuild(t *testing.T) {
originalBuild := Build
Build = "test-build"
defer func() { Build = originalBuild }()
if got, want := String(), "Cthulhu screen reader version test-build-"+Channel; got != want {
t.Fatalf("String() = %q, want %q", got, want)
}
}
func TestStringUsesCurrentVersionByDefault(t *testing.T) {
if Build != Version {
t.Fatalf("Build = %q, want %q", Build, Version)
}
if got, want := String(), "Cthulhu screen reader version "+Version+"-"+Channel; got != want {
t.Fatalf("String() = %q, want %q", got, want)
}
}
func TestDetailsIncludesATSPIAndSession(t *testing.T) {
got := Details("2.58.0", "x11", "GNOME", "")
want := "Cthulhu screen reader version " + Version + "-" + Channel + ", AT-SPI2 version: 2.58.0, Session: x11 GNOME"
if got != want {
t.Fatalf("Details() = %q, want %q", got, want)
}
if Details("2.58.0", " ", "", "") != strings.TrimSuffix(got, ", Session: x11 GNOME") {
t.Fatal("empty session information was included")
}
}
func TestDetailsIncludesOptionalWineAccess(t *testing.T) {
base := Details("2.58.0", "x11", "GNOME", "")
if got := Details("2.58.0", "x11", "GNOME", "2026.10.24"); got != base+", wine-access 2026.10.24" {
t.Fatalf("Details() = %q", got)
}
if got := Details("2.58.0", "x11", "GNOME", ""); got != base {
t.Fatalf("missing helper changed details: %q", got)
}
}