Skip to content

Commit

Permalink
This tests will be added in separate pr.
Browse files Browse the repository at this point in the history
  • Loading branch information
dekiel committed Dec 1, 2023
1 parent fd943b1 commit 1e029d9
Showing 1 changed file with 0 additions and 53 deletions.
53 changes: 0 additions & 53 deletions cmd/image-builder/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -566,56 +566,3 @@ type mockSigner struct {
func (m *mockSigner) Sign(images []string) error {
return m.signFunc(images)
}

func TestSignImages(t *testing.T) {
t.Run("orgRepo cannot be empty", func(t *testing.T) {
o := &options{}

err := signImages(o, []string{})

assert.Equal(t, "'orgRepo' cannot be empty", err.Error())
})

t.Run("Error when getting signers", func(t *testing.T) {
o := &options{
orgRepo: "org/repo",
}
orgRepoError := errors.New("org/repo error")
getSignersForOrgRepo = func(o *options, orgRepo string) ([]signer, error) {
return nil, orgRepoError
}
err := signImages(o, []string{"image1", "image2"})
assert.Equal(t, orgRepoError, err)
})

t.Run("Error when signing images", func(t *testing.T) {
o := &options{
orgRepo: "org/repo",
}
signError := errors.New("Signing error")
getSignersForOrgRepo = func(o *options, orgRepo string) ([]signer, error) {
return []signer{&mockSigner{
signFunc: func([]string) error {
return signError
},
}}, nil
}
err := signImages(o, []string{"image1", "image2"})
assert.Equal(t, "sign error: "+signError.Error(), err.Error())
})

t.Run("Successful signing", func(t *testing.T) {
o := &options{
orgRepo: "org/repo",
}
getSignersForOrgRepo = func(o *options, orgRepo string) ([]signer, error) {
return []signer{&mockSigner{
signFunc: func([]string) error {
return nil
},
}}, nil
}
err := signImages(o, []string{"image1", "image2"})
assert.Nil(t, err)
})
}

0 comments on commit 1e029d9

Please sign in to comment.