Skip to content

Commit

Permalink
chore: adds artifact tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jmgilman committed Jan 5, 2024
1 parent 0efbd44 commit 63434c2
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tools/fetcher/pkg/archive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var _ = Describe("Archive", func() {
}
})

It("should use the correct key and ID", func() {
It("should use the correct key", func() {
fetcher := pkg.NewArchiveFetcher("test", store)
_, err := fetcher.Fetch("id")
Expect(err).ToNot(HaveOccurred())
Expand Down
49 changes: 49 additions & 0 deletions tools/fetcher/pkg/artifact_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package pkg_test

import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"github.com/input-output-hk/catalyst-ci/tools/fetcher/pkg"
)

var _ = Describe("Artifact", func() {
Describe("Fetch", func() {
When("fetching an artifact", func() {
var store *MockStore
var usedKey string

BeforeEach(func() {
store = &MockStore{
FetchFunc: func(key string) ([]byte, error) {
usedKey = key
return []byte("artifact"), nil
},
}
})

It("should use the correct key", func() {
fetcher := pkg.NewArtifactFetcher("env", "fundx", store)
_, err := fetcher.Fetch("genesis", "1.0.0")
Expect(err).ToNot(HaveOccurred())
Expect(usedKey).To(Equal("env/fundx/block0.bin-1.0.0"))
})

It("should return the artifact", func() {
fetcher := pkg.NewArtifactFetcher("env", "fundx", store)
artifact, err := fetcher.Fetch("genesis", "1.0.0")
Expect(err).ToNot(HaveOccurred())
Expect(artifact).To(Equal([]byte("artifact")))
})

When("not specifying a version", func() {
It("should use the correct key", func() {
fetcher := pkg.NewArtifactFetcher("env", "fundx", store)
_, err := fetcher.Fetch("genesis", "")
Expect(err).ToNot(HaveOccurred())
Expect(usedKey).To(Equal("env/fundx/block0.bin"))
})
})
})
})
})

0 comments on commit 63434c2

Please sign in to comment.