2023-07-11 14:47:01 +01:00
|
|
|
package server
|
|
|
|
|
|
|
|
import (
|
2023-07-11 15:29:57 +01:00
|
|
|
"context"
|
2023-07-11 14:47:01 +01:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestPort(t *testing.T) {
|
|
|
|
th := SetupTestHelper(t)
|
|
|
|
defer th.TearDown()
|
|
|
|
|
|
|
|
port := th.srv.WebServer.Port()
|
|
|
|
require.NotEmpty(t, port)
|
|
|
|
}
|
2023-07-11 15:29:57 +01:00
|
|
|
|
|
|
|
func TestHealthHandler(t *testing.T) {
|
|
|
|
th := SetupTestHelper(t)
|
|
|
|
defer th.TearDown()
|
|
|
|
|
|
|
|
t.Run("should return ok if the server is up and running", func(t *testing.T) {
|
|
|
|
health, err := th.client.Health(context.Background())
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.True(t, health)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestNextBirthdaysHandler(t *testing.T) {
|
|
|
|
th := SetupTestHelper(t)
|
|
|
|
defer th.TearDown()
|
|
|
|
|
|
|
|
t.Run("should return a list if the server is up and running", func(t *testing.T) {
|
|
|
|
birthdays, err := th.client.NextBirthdays(context.Background())
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Len(t, birthdays, 1)
|
|
|
|
require.Equal(t, "john@doe.com", birthdays[0].Email)
|
|
|
|
})
|
|
|
|
}
|