health_test.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package main
  2. import (
  3. "net/http"
  4. "testing"
  5. )
  6. func TestReadinessCheck(t *testing.T) {
  7. client := getClient()
  8. resp, err := client.Get(baseURL + "/health/readiness")
  9. if err != nil {
  10. t.Errorf("Error getting response. %v", err)
  11. return
  12. }
  13. defer resp.Body.Close()
  14. if resp.StatusCode != http.StatusOK {
  15. t.Errorf("Wrong statuscode: %d", resp.StatusCode)
  16. return
  17. }
  18. t.Log("Readinesscheck OK.")
  19. }
  20. func TestHealthCheck(t *testing.T) {
  21. client := getClient()
  22. resp, err := client.Get(baseURL + "/health/health")
  23. if err != nil {
  24. t.Errorf("Error getting response. %v", err)
  25. return
  26. }
  27. defer resp.Body.Close()
  28. if resp.StatusCode != http.StatusOK {
  29. t.Errorf("Wrong statuscode: %d", resp.StatusCode)
  30. return
  31. }
  32. t.Log("Healthcheck OK.")
  33. }
  34. func TestSSLReadinessCheck(t *testing.T) {
  35. client := getClient()
  36. resp, err := client.Get(baseSslURL + "/health/readiness")
  37. if err != nil {
  38. t.Errorf("Error getting response. %v", err)
  39. return
  40. }
  41. defer resp.Body.Close()
  42. if resp.StatusCode != http.StatusOK {
  43. t.Errorf("Wrong statuscode: %d", resp.StatusCode)
  44. return
  45. }
  46. t.Log("SSL Readinesscheck OK.")
  47. }
  48. func TestSSLHealthCheck(t *testing.T) {
  49. client := getClient()
  50. resp, err := client.Get(baseSslURL + "/health/health")
  51. if err != nil {
  52. t.Errorf("Error getting response. %v", err)
  53. return
  54. }
  55. defer resp.Body.Close()
  56. if resp.StatusCode != http.StatusOK {
  57. t.Errorf("Wrong statuscode: %d", resp.StatusCode)
  58. return
  59. }
  60. t.Log("SSL Healthcheck OK.")
  61. }