Skip to content

Commit

Permalink
Pin digital ocean commit in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
maboehm committed May 7, 2024
1 parent 8a1d3ae commit a29a8e8
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions index/spec_index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ import (
"gopkg.in/yaml.v3"
)

const (
digitalOceanCommitID = "d8d390155b515cdd94555478bbcdf5682460c52e"
)

func TestSpecIndex_GetCache(t *testing.T) {
petstore, _ := os.ReadFile("../test_specs/petstorev3.json")
var rootNode yaml.Node
Expand Down Expand Up @@ -186,7 +190,7 @@ func TestSpecIndex_DigitalOcean(t *testing.T) {
// get all the files!
files := remoteFS.GetFiles()
fileLen := len(files)
assert.Equal(t, 1651, fileLen)
assert.Equal(t, 1654, fileLen)
assert.Len(t, remoteFS.GetErrors(), 0)

// check circular references
Expand All @@ -203,7 +207,11 @@ func TestSpecIndex_DigitalOcean_FullCheckoutLocalResolve(t *testing.T) {

err := cmd.Run()
if err != nil {
log.Fatalf("cmd.Run() failed with %s\n", err)
log.Fatalf("git clone failed with %s\n", err)
}

if err := exec.Command("git", "-C", tmp, "reset", "--hard", digitalOceanCommitID).Run(); err != nil {
log.Fatalf("git reset failed with %s\n", err)
}

spec, _ := filepath.Abs(filepath.Join(tmp, "specification", "DigitalOcean-public.v2.yaml"))
Expand Down Expand Up @@ -244,7 +252,7 @@ func TestSpecIndex_DigitalOcean_FullCheckoutLocalResolve(t *testing.T) {
files := fileFS.GetFiles()
fileLen := len(files)

assert.Equal(t, 1713, fileLen)
assert.Equal(t, 1716, fileLen)

rolo.AddLocalFS(basePath, fileFS)

Expand All @@ -270,7 +278,7 @@ func TestSpecIndex_DigitalOcean_FullCheckoutLocalResolve(t *testing.T) {
} else {
assert.Equal(t, "1.35 MB", rolo.RolodexFileSizeAsString())
}
assert.Equal(t, 1713, rolo.RolodexTotalFiles())
assert.Equal(t, 1716, rolo.RolodexTotalFiles())
}

func TestSpecIndex_DigitalOcean_FullCheckoutLocalResolve_RecursiveLookup(t *testing.T) {
Expand All @@ -281,7 +289,11 @@ func TestSpecIndex_DigitalOcean_FullCheckoutLocalResolve_RecursiveLookup(t *test

err := cmd.Run()
if err != nil {
log.Fatalf("cmd.Run() failed with %s\n", err)
log.Fatalf("git clone failed with %s\n", err)
}

if err := exec.Command("git", "-C", tmp, "reset", "--hard", digitalOceanCommitID).Run(); err != nil {
log.Fatalf("git reset failed with %s\n", err)
}

spec, _ := filepath.Abs(filepath.Join(tmp, "specification", "DigitalOcean-public.v2.yaml"))
Expand Down Expand Up @@ -324,7 +336,7 @@ func TestSpecIndex_DigitalOcean_FullCheckoutLocalResolve_RecursiveLookup(t *test
files := fileFS.GetFiles()
fileLen := len(files)

assert.Equal(t, 1699, fileLen)
assert.Equal(t, 1702, fileLen)

assert.NoError(t, rErr)

Expand All @@ -345,15 +357,15 @@ func TestSpecIndex_DigitalOcean_FullCheckoutLocalResolve_RecursiveLookup(t *test
} else {
assert.Equal(t, "1.24 MB", rolo.RolodexFileSizeAsString())
}
assert.Equal(t, 1699, rolo.RolodexTotalFiles())
assert.Equal(t, 1702, rolo.RolodexTotalFiles())
}

func TestSpecIndex_DigitalOcean_LookupsNotAllowed(t *testing.T) {
do, _ := os.ReadFile("../test_specs/digitalocean.yaml")
var rootNode yaml.Node
_ = yaml.Unmarshal(do, &rootNode)

location := "https://raw.githubusercontent.com/digitalocean/openapi/main/specification"
location := "https://raw.githubusercontent.com/digitalocean/openapi/tree/" + digitalOceanCommitID + "/specification"
baseURL, _ := url.Parse(location)

// create a new config that does not allow remote lookups.
Expand Down

0 comments on commit a29a8e8

Please sign in to comment.