diff --git a/.config/dictionaries/project.dic b/.config/dictionaries/project.dic index a30381b51..c165f5dff 100644 --- a/.config/dictionaries/project.dic +++ b/.config/dictionaries/project.dic @@ -21,10 +21,12 @@ golangci GOLANGCI golines golint +gomega GOMODCACHE gopls gosec graphviz +jormungandr Kroki kubeconfig ldflags diff --git a/cspell.json b/cspell.json index db8a678a2..db121ae9e 100644 --- a/cspell.json +++ b/cspell.json @@ -40,6 +40,8 @@ ".markdownlint.jsonc", ".markdownlint-cli2.jsonc", ".envrc", - "cspell.json" + "cspell.json", + "**/**/go.mod", + "**/**/go.sum", ] } \ No newline at end of file diff --git a/tools/fetcher/pkg/archive_test.go b/tools/fetcher/pkg/archive_test.go new file mode 100644 index 000000000..b5852ec24 --- /dev/null +++ b/tools/fetcher/pkg/archive_test.go @@ -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"))) + }) + }) + }) +}) diff --git a/tools/fetcher/pkg/pkg_suite_test.go b/tools/fetcher/pkg/pkg_suite_test.go new file mode 100644 index 000000000..a60f6c7f4 --- /dev/null +++ b/tools/fetcher/pkg/pkg_suite_test.go @@ -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) +} diff --git a/tools/fetcher/pkg/store/aws.go b/tools/fetcher/pkg/store/aws.go index 510c93eb0..8f3937c8a 100644 --- a/tools/fetcher/pkg/store/aws.go +++ b/tools/fetcher/pkg/store/aws.go @@ -1,5 +1,7 @@ package store +// cspell: words iface + import ( "fmt" "io" diff --git a/tools/fetcher/pkg/store/aws_test.go b/tools/fetcher/pkg/store/aws_test.go index 0b09e1358..9b2f73c5f 100644 --- a/tools/fetcher/pkg/store/aws_test.go +++ b/tools/fetcher/pkg/store/aws_test.go @@ -1,5 +1,7 @@ package store_test +// cspell: words iface onsi gomega + import ( "bytes" "fmt"