mirror of
https://github.com/hashicorp/vault.git
synced 2026-02-03 20:40:45 -05:00
* [VAULT-41857] pipeline(find-artifact): add support for finding artifacts from branches (#11799) Add support for finding matching workflow artifacts from branches rather than PRs. This allows us to trigger custom HCP image builds from a branch rather than an PR. It also enables us to build and test the HCP image on a scheduled nightly cadence, which we've also enabled. As part of these changes I also added support for specifying which environment you want to test and threaded it through the cloud scenario now that there are multiple variants. We also make the testing workflow workflow_dispatch-able so that we can trigger HVD testing for any custom image in any environment without building a new image. Signed-off-by: Ryan Cragun <me@ryan.ec> Co-authored-by: Ryan Cragun <me@ryan.ec>
86 lines
2.6 KiB
Go
86 lines
2.6 KiB
Go
// Copyright IBM Corp. 2016, 2025
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
package github
|
|
|
|
import (
|
|
"testing"
|
|
|
|
libgithub "github.com/google/go-github/v81/github"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func Test_CopyPullRequest_getCoAuthoredByTrailers(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
for name, test := range map[string]struct {
|
|
commits []*libgithub.RepositoryCommit
|
|
expected []string
|
|
}{
|
|
"no commits": {
|
|
nil,
|
|
nil,
|
|
},
|
|
"one author one commit": {
|
|
[]*libgithub.RepositoryCommit{
|
|
{Commit: &libgithub.Commit{Author: &libgithub.CommitAuthor{
|
|
Name: libgithub.Ptr("John Doe"),
|
|
Email: libgithub.Ptr("john@example.com"),
|
|
}}},
|
|
},
|
|
[]string{"Co-Authored-By: John Doe <john@example.com>"},
|
|
},
|
|
"one author multiple commits": {
|
|
[]*libgithub.RepositoryCommit{
|
|
{Commit: &libgithub.Commit{Author: &libgithub.CommitAuthor{
|
|
Name: libgithub.Ptr("John Doe"),
|
|
Email: libgithub.Ptr("john@example.com"),
|
|
}}},
|
|
{Commit: &libgithub.Commit{Author: &libgithub.CommitAuthor{
|
|
Name: libgithub.Ptr("John Doe"),
|
|
Email: libgithub.Ptr("john@example.com"),
|
|
}}},
|
|
},
|
|
[]string{"Co-Authored-By: John Doe <john@example.com>"},
|
|
},
|
|
"multiple authors with one commit each": {
|
|
[]*libgithub.RepositoryCommit{
|
|
{Commit: &libgithub.Commit{Author: &libgithub.CommitAuthor{
|
|
Name: libgithub.Ptr("John Doe"),
|
|
Email: libgithub.Ptr("john@example.com"),
|
|
}}},
|
|
{Commit: &libgithub.Commit{Author: &libgithub.CommitAuthor{
|
|
Name: libgithub.Ptr("Jane Doe"),
|
|
Email: libgithub.Ptr("jane@example.com"),
|
|
}}},
|
|
},
|
|
[]string{"Co-Authored-By: John Doe <john@example.com>", "Co-Authored-By: Jane Doe <jane@example.com>"},
|
|
},
|
|
"multiple authors with multiple commits": {
|
|
[]*libgithub.RepositoryCommit{
|
|
{Commit: &libgithub.Commit{Author: &libgithub.CommitAuthor{
|
|
Name: libgithub.Ptr("John Doe"),
|
|
Email: libgithub.Ptr("john@example.com"),
|
|
}}},
|
|
{Commit: &libgithub.Commit{Author: &libgithub.CommitAuthor{
|
|
Name: libgithub.Ptr("Jane Doe"),
|
|
Email: libgithub.Ptr("jane@example.com"),
|
|
}}},
|
|
{Commit: &libgithub.Commit{Author: &libgithub.CommitAuthor{
|
|
Name: libgithub.Ptr("Jane Doe"),
|
|
Email: libgithub.Ptr("jane@example.com"),
|
|
}}},
|
|
{Commit: &libgithub.Commit{Author: &libgithub.CommitAuthor{
|
|
Name: libgithub.Ptr("John Doe"),
|
|
Email: libgithub.Ptr("john@example.com"),
|
|
}}},
|
|
},
|
|
[]string{"Co-Authored-By: John Doe <john@example.com>", "Co-Authored-By: Jane Doe <jane@example.com>"},
|
|
},
|
|
} {
|
|
t.Run(name, func(t *testing.T) {
|
|
req := &CopyPullRequestReq{}
|
|
require.EqualValues(t, test.expected, req.getCoAuthoredByTrailers(test.commits))
|
|
})
|
|
}
|
|
}
|