Skip to content

Commit

Permalink
Merge branch 'main' into fix/routes/GetTransit
Browse files Browse the repository at this point in the history
  • Loading branch information
michealroberts committed Jun 21, 2022
2 parents b202ded + c0017d0 commit 0bb1222
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
4 changes: 2 additions & 2 deletions coverage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ github.com/observerly/nocturnal/internal/router/setup.go:58.41,65.3 1 1
github.com/observerly/nocturnal/internal/router/setup.go:68.40,77.3 1 1
github.com/observerly/nocturnal/internal/router/setup.go:80.33,82.3 1 1
github.com/observerly/nocturnal/pkg/twilight/twilight.go:14.34,75.2 14 1
github.com/observerly/nocturnal/pkg/sun/sun.go:15.29,57.2 13 1
github.com/observerly/nocturnal/pkg/moon/moon.go:15.30,61.22 16 1
github.com/observerly/nocturnal/pkg/moon/moon.go:67.2,67.21 1 1
github.com/observerly/nocturnal/pkg/moon/moon.go:73.2,78.4 1 1
github.com/observerly/nocturnal/pkg/moon/moon.go:61.22,63.3 1 0
github.com/observerly/nocturnal/pkg/moon/moon.go:63.8,65.3 1 1
github.com/observerly/nocturnal/pkg/moon/moon.go:67.21,69.3 1 0
github.com/observerly/nocturnal/pkg/moon/moon.go:69.8,71.3 1 1
github.com/observerly/nocturnal/pkg/sun/sun.go:15.29,57.2 13 1
github.com/observerly/nocturnal/pkg/transit/transit.go:15.33,90.2 24 3
github.com/observerly/nocturnal/pkg/transit/transit.go:15.33,93.2 25 3
3 changes: 3 additions & 0 deletions pkg/transit/transit.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ func GetTransit(c *gin.Context) {

tr, _ := dusk.GetObjectTransit(datetime, eq, latitude, longitude)

path, _ := dusk.GetObjectHorizontalCoordinatesForDay(datetime, eq, longitude, latitude)

airmass := dusk.GetRelativeAirMass(hz.Altitude)

refraction := dusk.GetAtmosphericRefraction(hz.Altitude)
Expand Down Expand Up @@ -79,6 +81,7 @@ func GetTransit(c *gin.Context) {
"maximum": utils.FormatDatetimeRFC3339(tr.Maximum),
"rise": utils.FormatDatetimeRFC3339(tr.Rise),
"set": utils.FormatDatetimeRFC3339(tr.Set),
"path": path,
}

c.JSON(http.StatusOK, gin.H{
Expand Down
17 changes: 13 additions & 4 deletions pkg/transit/transit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"testing"

"github.com/gin-gonic/gin"
"github.com/observerly/dusk/pkg/dusk"
"github.com/observerly/nocturnal/internal/utils"
"github.com/stretchr/testify/assert"
)

Expand All @@ -30,7 +32,7 @@ func SetupTransitRouter() *gin.Engine {
var r = SetupTransitRouter()

// Setup the base response struct:
var response map[string]map[string]string
var response map[string]map[string]interface{}

func performRequest(r http.Handler, method, path string) *httptest.ResponseRecorder {
req, _ := http.NewRequest(method, path, nil)
Expand Down Expand Up @@ -170,11 +172,18 @@ func TestGetTransitRoutePosition(t *testing.T) {
}

func TestGetTransitRouteTransit(t *testing.T) {
datetime, _ := utils.ParseDatetimeRFC3339("2021-05-14T00:00:00.000Z")

eq := dusk.EquatorialCoordinate{RightAscension: 88.792958, Declination: 7.407064}

coordinates, _ := dusk.GetObjectHorizontalCoordinatesForDay(datetime, eq, -155.468094, 19.798484)

// Build our expected transit section of body
transit := gin.H{
"maximum": "2021-05-14T12:39:25-10:00",
"rise": "2021-05-14T08:35:25-10:00",
"set": "2021-05-14T20:54:51-10:00",
"path": coordinates,
}

// Convert the JSON response:
Expand Down Expand Up @@ -222,9 +231,9 @@ func TestGetTransitRouteTransitAlt(t *testing.T) {
func TestGetTransitRouteTransitNotAboveHorizon(t *testing.T) {
// Build our expected transit section of body
transit := gin.H{
"maximum": "",
"rise": "",
"set": "",
"maximum": nil,
"rise": nil,
"set": nil,
}

// Convert the JSON response:
Expand Down

0 comments on commit 0bb1222

Please sign in to comment.