utils_test.go 941 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package conf
  2. import (
  3. "path/filepath"
  4. "testing"
  5. "github.com/stretchr/testify/assert"
  6. )
  7. func Test_cleanUpOpenSSHVersion(t *testing.T) {
  8. tests := []struct {
  9. raw string
  10. want string
  11. }{
  12. {
  13. raw: "OpenSSH_7.4p1 Ubuntu-10, OpenSSL 1.0.2g 1 Mar 2016",
  14. want: "7.4",
  15. }, {
  16. raw: "OpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013",
  17. want: "5.3",
  18. }, {
  19. raw: "OpenSSH_4.3p2, OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008",
  20. want: "4.3",
  21. },
  22. }
  23. for _, test := range tests {
  24. t.Run("", func(t *testing.T) {
  25. assert.Equal(t, test.want, cleanUpOpenSSHVersion(test.raw))
  26. })
  27. }
  28. }
  29. func Test_ensureAbs(t *testing.T) {
  30. wd := WorkDir()
  31. tests := []struct {
  32. path string
  33. want string
  34. }{
  35. {
  36. path: "data/avatars",
  37. want: filepath.Join(wd, "data", "avatars"),
  38. }, {
  39. path: wd,
  40. want: wd,
  41. },
  42. }
  43. for _, test := range tests {
  44. t.Run("", func(t *testing.T) {
  45. assert.Equal(t, test.want, ensureAbs(test.path))
  46. })
  47. }
  48. }