api_integration_test.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
  2. // SPDX-License-Identifier: Apache-2.0
  3. package api_test
  4. import (
  5. "errors"
  6. "testing"
  7. miniflux "miniflux.app/v2/client"
  8. "miniflux.app/v2/internal/http/server/servertest"
  9. )
  10. func TestHealthcheckEndpoint(t *testing.T) {
  11. t.Parallel()
  12. client := miniflux.NewClient(servertest.Require(t).URL)
  13. if err := client.Healthcheck(); err != nil {
  14. t.Fatal(err)
  15. }
  16. }
  17. func TestVersionEndpoint(t *testing.T) {
  18. t.Parallel()
  19. client := newAdminClient(t)
  20. version, err := client.Version()
  21. if err != nil {
  22. t.Fatal(err)
  23. }
  24. if version.Version == "" {
  25. t.Fatal(`Version should not be empty`)
  26. }
  27. if version.Commit == "" {
  28. t.Fatal(`Commit should not be empty`)
  29. }
  30. if version.BuildDate == "" {
  31. t.Fatal(`Build date should not be empty`)
  32. }
  33. if version.GoVersion == "" {
  34. t.Fatal(`Go version should not be empty`)
  35. }
  36. if version.Compiler == "" {
  37. t.Fatal(`Compiler should not be empty`)
  38. }
  39. if version.Arch == "" {
  40. t.Fatal(`Arch should not be empty`)
  41. }
  42. if version.OS == "" {
  43. t.Fatal(`OS should not be empty`)
  44. }
  45. }
  46. func TestInvalidCredentials(t *testing.T) {
  47. t.Parallel()
  48. client := miniflux.NewClient(servertest.Require(t).URL, "invalid", "invalid")
  49. _, err := client.Users()
  50. if !errors.Is(err, miniflux.ErrNotAuthorized) {
  51. t.Fatalf(`Using bad credentials should raise a "not authorized" error, got %v`, err)
  52. }
  53. }