mirror of
https://github.com/miniflux/v2.git
synced 2025-08-26 18:21:01 +00:00
test(version): add a test to enforce the version format
This commit is contained in:
parent
b25f9651fe
commit
49575c8902
1 changed files with 34 additions and 0 deletions
34
internal/version/version_test.go
Normal file
34
internal/version/version_test.go
Normal file
|
@ -0,0 +1,34 @@
|
|||
// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package version // import "miniflux.app/v2/internal/version"
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
"unicode"
|
||||
)
|
||||
|
||||
// Some Miniflux clients expect a specific version format with at least a digit.
|
||||
func TestVersionConvertedToInteger(t *testing.T) {
|
||||
var b strings.Builder
|
||||
for _, r := range Version {
|
||||
if unicode.IsDigit(r) {
|
||||
b.WriteRune(r)
|
||||
}
|
||||
}
|
||||
|
||||
if b.Len() == 0 {
|
||||
t.Fatalf("Expected version to contain digits, got %q", Version)
|
||||
}
|
||||
|
||||
versionInt, err := strconv.ParseInt(b.String(), 10, 64)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to convert version to integer: %v", err)
|
||||
}
|
||||
|
||||
if versionInt <= 0 {
|
||||
t.Errorf("Expected version integer to be greater than 0, got %d", versionInt)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue