Files
Gogs/internal/conf/utils_test.go
ᴊᴏᴇ ᴄʜᴇɴ 59e9fa191b chore: remove all MIT license file headers (#8083)
Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
2026-01-08 19:32:15 -05:00

54 lines
941 B
Go

package conf
import (
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
)
func Test_cleanUpOpenSSHVersion(t *testing.T) {
tests := []struct {
raw string
want string
}{
{
raw: "OpenSSH_7.4p1 Ubuntu-10, OpenSSL 1.0.2g 1 Mar 2016",
want: "7.4",
}, {
raw: "OpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013",
want: "5.3",
}, {
raw: "OpenSSH_4.3p2, OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008",
want: "4.3",
},
}
for _, test := range tests {
t.Run("", func(t *testing.T) {
assert.Equal(t, test.want, cleanUpOpenSSHVersion(test.raw))
})
}
}
func Test_ensureAbs(t *testing.T) {
wd := WorkDir()
tests := []struct {
path string
want string
}{
{
path: "data/avatars",
want: filepath.Join(wd, "data", "avatars"),
}, {
path: wd,
want: wd,
},
}
for _, test := range tests {
t.Run("", func(t *testing.T) {
assert.Equal(t, test.want, ensureAbs(test.path))
})
}
}