💥 Reorder date arguments in GetViews method

From 'hh/dd/mm/yyyy' to 'yyyy/mm/dd/hh' format
This commit is contained in:
Maxim Lebedev 2017-12-13 15:41:53 +05:00
parent ffbe39bb83
commit acc34522b5
No known key found for this signature in database
GPG Key ID: F8978F46FF0FFA4F
3 changed files with 7 additions and 7 deletions

View File

@ -15,7 +15,7 @@ type PageViews struct {
// GetViews get the number of views for a Telegraph article. By default, the total number of page
// views will be returned. Returns a PageViews object on success.
func GetViews(path string, hour, day, month, year int) (*PageViews, error) {
func GetViews(path string, year, month, day, hour int) (*PageViews, error) {
args := http.AcquireArgs()
if hour > -1 {

View File

@ -86,31 +86,31 @@ func TestInvalidGetPage(t *testing.T) {
}
func TestInvalidGetViewsByPage(t *testing.T) {
if _, err := GetViews(validPageURL, 2016, 12, 0, -1); err == nil {
if _, err := GetViews(invalidPageURL, 2016, 12, 0, -1); err == nil {
t.Error()
}
}
func TestInvalidGetViewsByHour(t *testing.T) {
if _, err := GetViews(validPageURL, 42, 0, 0, 0); err == nil {
if _, err := GetViews(validPageURL, 0, 0, 0, 42); err == nil {
t.Error()
}
}
func TestInvalidGetViewsByDay(t *testing.T) {
if _, err := GetViews(validPageURL, 23, 42, 0, 0); err == nil {
if _, err := GetViews(validPageURL, 0, 0, 42, 23); err == nil {
t.Error()
}
}
func TestInvalidGetViewsByMonth(t *testing.T) {
if _, err := GetViews(validPageURL, 23, 24, 22, 0); err == nil {
if _, err := GetViews(validPageURL, 0, 22, 24, 23); err == nil {
t.Error()
}
}
func TestInvalidGetViewsByYear(t *testing.T) {
if _, err := GetViews(validPageURL, 23, 24, 12, 1980); err == nil {
if _, err := GetViews(validPageURL, 1980, 12, 24, 23); err == nil {
t.Error()
}
}

View File

@ -148,7 +148,7 @@ func testValidGetPageList(t *testing.T) {
}
func TestValidGetViews(t *testing.T) {
stats, err := GetViews(validPageURL, -1, 0, 12, 2016)
stats, err := GetViews(validPageURL, 2016, 12, 0, -1)
if err != nil {
t.Error(err.Error())
t.FailNow()