Skip to content
This repository has been archived by the owner on Mar 24, 2023. It is now read-only.

Commit

Permalink
Add test for content sha
Browse files Browse the repository at this point in the history
  • Loading branch information
marccampbell committed Aug 7, 2018
1 parent 6a1b373 commit 7fc27f0
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/cli/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func Watch() *cobra.Command {
cmd := &cobra.Command{
Use: "watch",
Short: "Watch an upstream for updates",
Long: `Watch will poll the upstream source for changes, and block until a
Long: `Watch will poll the upstream source for changes, and block until a
change has been published. The watch command will return with an exit code
of 0 when there's an update available.`,
RunE: func(cmd *cobra.Command, args []string) error {
Expand Down
29 changes: 29 additions & 0 deletions pkg/specs/chart_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ import (
"github.com/go-kit/kit/log"

"github.com/replicatedhq/ship/pkg/constants"
"github.com/replicatedhq/ship/pkg/state"

"github.com/google/go-github/github"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/spf13/afero"
"github.com/spf13/viper"
)

var client *github.Client
Expand Down Expand Up @@ -151,6 +153,33 @@ var _ = Describe("GithubClient", func() {
})
})
})

Describe("calculateContentSHA", func() {
Context("With multiple files", func() {
It("should calculate the same sha, mulitple times", func() {
mockFs := afero.Afero{Fs: afero.NewMemMapFs()}
mockFs.WriteFile("Chart.yaml", []byte("chart.yaml"), 0755)
mockFs.WriteFile("templates/README.md", []byte("readme"), 0755)

r := Resolver{
FS: mockFs,
StateManager: &state.MManager{
Logger: log.NewNopLogger(),
FS: mockFs,
V: viper.New(),
},
}

firstPass, err := r.calculateContentSHA("")
Expect(err).NotTo(HaveOccurred())

secondPass, err := r.calculateContentSHA("")
Expect(err).NotTo(HaveOccurred())

Expect(firstPass).To(Equal(secondPass))
})
})
})
})

var _ = AfterSuite(func() {
Expand Down
25 changes: 25 additions & 0 deletions pkg/test-mocks/dockerlayer/archive_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions pkg/test-mocks/state/manager_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7fc27f0

Please sign in to comment.