💥 Reorder date arguments in GetViews method
From 'hh/dd/mm/yyyy' to 'yyyy/mm/dd/hh' format
This commit is contained in:
parent
ffbe39bb83
commit
acc34522b5
|
@ -15,7 +15,7 @@ type PageViews struct {
|
||||||
|
|
||||||
// GetViews get the number of views for a Telegraph article. By default, the total number of page
|
// 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.
|
// 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()
|
args := http.AcquireArgs()
|
||||||
|
|
||||||
if hour > -1 {
|
if hour > -1 {
|
||||||
|
|
|
@ -86,31 +86,31 @@ func TestInvalidGetPage(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestInvalidGetViewsByPage(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()
|
t.Error()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestInvalidGetViewsByHour(t *testing.T) {
|
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()
|
t.Error()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestInvalidGetViewsByDay(t *testing.T) {
|
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()
|
t.Error()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestInvalidGetViewsByMonth(t *testing.T) {
|
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()
|
t.Error()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestInvalidGetViewsByYear(t *testing.T) {
|
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()
|
t.Error()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,7 +148,7 @@ func testValidGetPageList(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestValidGetViews(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 {
|
if err != nil {
|
||||||
t.Error(err.Error())
|
t.Error(err.Error())
|
||||||
t.FailNow()
|
t.FailNow()
|
||||||
|
|
Loading…
Reference in New Issue