-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: fixes spelling and adds archive tests
- Loading branch information
Showing
6 changed files
with
69 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package pkg_test | ||
|
||
import ( | ||
"github.com/input-output-hk/catalyst-ci/tools/fetcher/pkg" | ||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("Archive", func() { | ||
Describe("Fetch", func() { | ||
When("fetching an archive", func() { | ||
var store *MockStore | ||
var usedKey string | ||
|
||
BeforeEach(func() { | ||
store = &MockStore{ | ||
FetchFunc: func(key string) ([]byte, error) { | ||
usedKey = key | ||
return []byte("archive"), nil | ||
}, | ||
} | ||
}) | ||
|
||
It("should use the correct key and ID", func() { | ||
fetcher := pkg.NewArchiveFetcher("test", store) | ||
_, err := fetcher.Fetch("id") | ||
Expect(err).ToNot(HaveOccurred()) | ||
Expect(usedKey).To(Equal("test/id")) | ||
}) | ||
|
||
It("should return the archive", func() { | ||
fetcher := pkg.NewArchiveFetcher("test", store) | ||
archive, err := fetcher.Fetch("id") | ||
Expect(err).ToNot(HaveOccurred()) | ||
Expect(archive).To(Equal([]byte("archive"))) | ||
}) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package pkg_test | ||
|
||
import ( | ||
"testing" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
func TestPkg(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "Pkg Suite") | ||
} | ||
|
||
type MockStore struct { | ||
FetchFunc func(key string) ([]byte, error) | ||
} | ||
|
||
func (m *MockStore) Fetch(key string) ([]byte, error) { | ||
return m.FetchFunc(key) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
package store | ||
|
||
// cspell: words iface | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
package store_test | ||
|
||
// cspell: words iface onsi gomega | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
|