You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.2 KiB
Go
52 lines
1.2 KiB
Go
package diyanetapi
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"prayertimes/internal/net"
|
|
"prayertimes/pkg/prayer"
|
|
)
|
|
|
|
func TestDiyanetAPI_GetByCoords(t *testing.T) {
|
|
p := New(net.ReqClient)
|
|
t.Run("by coords", func(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
result, err := p.GetByCoords(context.Background(), prayer.Coordinates{
|
|
Latitude: 52.5100846,
|
|
Longitude: 13.4518284,
|
|
})
|
|
if err != nil {
|
|
t.Skipf("skipping live endpoint test due to upstream/network error: %v", err)
|
|
}
|
|
if len(result.Times) == 0 {
|
|
t.Skip("skipping live endpoint test because upstream returned no times")
|
|
}
|
|
|
|
assert.NoError(t, err)
|
|
assert.NotEmpty(t, result.Times)
|
|
t.Logf("location=%+v first=%+v", result.Location, result.Times[0])
|
|
})
|
|
|
|
t.Run("by id", func(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
result, err := p.Get(context.Background(), "11104")
|
|
if err != nil {
|
|
t.Skipf("skipping live endpoint test due to upstream/network error: %v", err)
|
|
}
|
|
if len(result.Times) == 0 {
|
|
t.Skip("skipping live endpoint test because upstream returned no times")
|
|
}
|
|
|
|
assert.NoError(t, err)
|
|
assert.NotEmpty(t, result.Times)
|
|
for _, item := range result.Times {
|
|
t.Log(item)
|
|
}
|
|
})
|
|
}
|