Skip to content

Commit

Permalink
fix: amend GetUTCDate() in telescope module in @observerly/alpacago.
Browse files Browse the repository at this point in the history
fix: amend GetUTCDate() in telescope module in @observerly/alpacago.
  • Loading branch information
michealroberts committed May 15, 2024
1 parent 79673e9 commit bf068a0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
4 changes: 2 additions & 2 deletions coverage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -380,5 +380,5 @@ github.com/observerly/alpacago/pkg/alpacago/telescope.go:1039.81,1049.2 3 1
github.com/observerly/alpacago/pkg/alpacago/telescope.go:1057.48,1059.2 1 1
github.com/observerly/alpacago/pkg/alpacago/telescope.go:1067.54,1077.2 3 15
github.com/observerly/alpacago/pkg/alpacago/telescope.go:1085.54,1087.2 1 1
github.com/observerly/alpacago/pkg/alpacago/telescope.go:1098.53,1102.2 3 1
github.com/observerly/alpacago/pkg/alpacago/telescope.go:1113.57,1126.2 4 1
github.com/observerly/alpacago/pkg/alpacago/telescope.go:1098.53,1105.2 4 1
github.com/observerly/alpacago/pkg/alpacago/telescope.go:1116.57,1129.2 4 1
8 changes: 6 additions & 2 deletions pkg/alpacago/telescope.go
Original file line number Diff line number Diff line change
Expand Up @@ -1097,8 +1097,12 @@ Z indicating the 'Zulu', UTC time zone.
*/
func (t *Telescope) GetUTCDate() (time.Time, error) {
utc, err := t.Alpaca.GetStringResponse("telescope", t.DeviceNumber, "utcdate")
date, _ := time.Parse("yyyy-MM-ddTHH:mm:ss.fffffffZ", utc)
return date, err

if err != nil {
return time.Time{}, err
}

return time.Parse("2006-01-02T15:04:05.000", utc)
}

/*
Expand Down
12 changes: 3 additions & 9 deletions pkg/alpacago/telescope_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1126,20 +1126,14 @@ func TestNewTelescopeGetTrackingRate(t *testing.T) {
}

func TestNewTelescopeGetUTCDate(t *testing.T) {
var got, err = telescope.GetUTCDate()

var want time.Time = time.Date(1, 1, 1, 0, 0, 0, 0, time.UTC)
var _, err = telescope.GetUTCDate()

if err != nil {
t.Errorf("got %q, wanted %q", err, want.String())
}

if got != want {
t.Errorf("got %q, wanted %q", got, want.String())
t.Errorf("got %q", err)
}

if telescope.Alpaca.ErrorNumber != 0 && telescope.Alpaca.ErrorMessage != "" {
t.Errorf("got %q, wanted %q", telescope.Alpaca.ErrorMessage, want.String())
t.Errorf("got %q", telescope.Alpaca.ErrorMessage)
}
}

Expand Down

0 comments on commit bf068a0

Please sign in to comment.