Skip to content

Commit

Permalink
For now make github repository test (which really is an integration t…
Browse files Browse the repository at this point in the history
…est) sleep 100ms after each REST call to prevent rate limiting errors -> let us hope it works. Eventually we should mock this REST api calls.

Signed-off-by: Waldemar Kozaczuk <jwkozaczuk@gmail.com>
  • Loading branch information
wkozaczuk committed Aug 2, 2019
1 parent af49752 commit 5b4cb17
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions util/github_releases_repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package util

import (
. "gopkg.in/check.v1"
"time"
)

type suite struct {
Expand All @@ -20,25 +21,32 @@ func (s *suite) TestGithubPackageInfoRemote(c *C) {
s.repo.ReleaseTag = "v0.53.0"
packageName := "osv.httpserver-api"
appPackage := s.repo.PackageInfoRemote(packageName)
//TODO: For now let us use sleep to prevent github REST API calls fail
// due to rate limiting. Eventually we should mock the REST api
// (please see https://medium.com/@tech_phil/how-to-stub-external-services-in-go-8885704e8c53)
time.Sleep(100 * time.Millisecond)
c.Assert(appPackage, NotNil)
c.Check(appPackage.Name, Equals, packageName)
}

func (s *suite) TestGithubDownloadLoaderImage(c *C) {
s.repo.ReleaseTag = "v0.51.0"
loaderName, err := s.repo.DownloadLoaderImage("qemu")
time.Sleep(100 * time.Millisecond)
c.Assert(err, IsNil)
c.Check(loaderName, Equals, "osv-loader")
}

func (s *suite) TestGithubListPackagesRemote(c *C) {
s.repo.ReleaseTag = "any"
err := s.repo.ListPackagesRemote("")
time.Sleep(100 * time.Millisecond)
c.Assert(err, IsNil)
}

func (s *suite) TestGithubDownloadPackageRemote(c *C) {
s.repo.ReleaseTag = "v0.53.0"
err := s.repo.DownloadPackageRemote("osv.httpserver-api")
time.Sleep(100 * time.Millisecond)
c.Assert(err, IsNil)
}

0 comments on commit 5b4cb17

Please sign in to comment.