hostinfo_linux_test.go 992 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright (c) Tailscale Inc & AUTHORS
  2. // SPDX-License-Identifier: BSD-3-Clause
  3. //go:build linux && !android && !ts_package_container
  4. package hostinfo
  5. import (
  6. "testing"
  7. )
  8. func TestQnap(t *testing.T) {
  9. version_info := `commit 2910d3a594b068024ed01a64a0fe4168cb001a12
  10. Date: 2022-05-30 16:08:45 +0800
  11. ================================================
  12. * QTSFW_5.0.0
  13. remotes/origin/QTSFW_5.0.0`
  14. got := getQnapQtsVersion(version_info)
  15. want := "5.0.0"
  16. if got != want {
  17. t.Errorf("got %q; want %q", got, want)
  18. }
  19. got = getQnapQtsVersion("")
  20. want = ""
  21. if got != want {
  22. t.Errorf("got %q; want %q", got, want)
  23. }
  24. got = getQnapQtsVersion("just a bunch of junk")
  25. want = ""
  26. if got != want {
  27. t.Errorf("got %q; want %q", got, want)
  28. }
  29. }
  30. func TestPackageTypeNotContainer(t *testing.T) {
  31. var got string
  32. if packageType != nil {
  33. got = packageType()
  34. }
  35. if got == "container" {
  36. t.Fatal("packageType = container; should only happen if build tag ts_package_container is set")
  37. }
  38. }