Skip to content

Commit

Permalink
chore: fixes spelling and adds archive tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jmgilman committed Jan 5, 2024
1 parent 7aa4dfc commit 0efbd44
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .config/dictionaries/project.dic
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ golangci
GOLANGCI
golines
golint
gomega
GOMODCACHE
gopls
gosec
graphviz
jormungandr
Kroki
kubeconfig
ldflags
Expand Down
4 changes: 3 additions & 1 deletion cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
".markdownlint.jsonc",
".markdownlint-cli2.jsonc",
".envrc",
"cspell.json"
"cspell.json",
"**/**/go.mod",
"**/**/go.sum",
]
}
39 changes: 39 additions & 0 deletions tools/fetcher/pkg/archive_test.go
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")))
})
})
})
})
21 changes: 21 additions & 0 deletions tools/fetcher/pkg/pkg_suite_test.go
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)
}
2 changes: 2 additions & 0 deletions tools/fetcher/pkg/store/aws.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package store

// cspell: words iface

import (
"fmt"
"io"
Expand Down
2 changes: 2 additions & 0 deletions tools/fetcher/pkg/store/aws_test.go
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"
Expand Down

0 comments on commit 0efbd44

Please sign in to comment.