Compare commits

...

2 commits

4 changed files with 10 additions and 10 deletions

View file

@ -23,7 +23,7 @@ var e2eMutateCmd = &cobra.Command{
func init() { func init() {
rootCmd.AddCommand(e2eMutateCmd) rootCmd.AddCommand(e2eMutateCmd)
e2eMutateCmd.Flags().StringVar(&e2eMutateForgejoURL, "forgejo-url", "", "Credential-free Forgejo base URL") e2eMutateCmd.Flags().StringVar(&e2eMutateForgejoURL, "forgejo-url", "", "Credential-free Forgejo base URL")
e2eMutateCmd.Flags().StringVar(&e2eMutateOwner, "owner", "", "Fixture Forgejo owner (must be test-org-2)") e2eMutateCmd.Flags().StringVar(&e2eMutateOwner, "owner", "", "Fixture Forgejo owner (must be Maidn)")
e2eMutateCmd.Flags().StringVar(&e2eMutateRepo, "repo", "", "Fixture Forgejo repository (must start maidn-e2e-)") e2eMutateCmd.Flags().StringVar(&e2eMutateRepo, "repo", "", "Fixture Forgejo repository (must start maidn-e2e-)")
e2eMutateCmd.Flags().StringVar(&e2eMutateBranch, "branch", "", "Fixture Forgejo branch (must start maidn-e2e-)") e2eMutateCmd.Flags().StringVar(&e2eMutateBranch, "branch", "", "Fixture Forgejo branch (must start maidn-e2e-)")
e2eMutateCmd.Flags().StringVar(&e2eMutateSHA, "sha", "", "Full Git object ID for the fixture branch") e2eMutateCmd.Flags().StringVar(&e2eMutateSHA, "sha", "", "Full Git object ID for the fixture branch")

View file

@ -35,7 +35,7 @@ func TestE2EMutateCommandWiringUsesOnlyTokenReferences(t *testing.T) {
} }
fake := &commandMutationHTTP{} fake := &commandMutationHTTP{}
e2eMutator = func() e2emutate.Mutator { return e2emutate.Mutator{HTTP: fake} } e2eMutator = func() e2emutate.Mutator { return e2emutate.Mutator{HTTP: fake} }
e2eMutateForgejoURL, e2eMutateOwner = "https://git.example.test", "test-org-2" e2eMutateForgejoURL, e2eMutateOwner = "https://git.example.test", "Maidn"
e2eMutateRepo, e2eMutateBranch = "maidn-e2e-repo", "maidn-e2e-branch" e2eMutateRepo, e2eMutateBranch = "maidn-e2e-repo", "maidn-e2e-branch"
e2eMutateSHA = "0123456789abcdef0123456789abcdef01234567" e2eMutateSHA = "0123456789abcdef0123456789abcdef01234567"
e2eMutateTokenEnv, e2eMutateTokenFile, e2eMutateOpenPR = "E2E_MUTATE_TEST_TOKEN", "", false e2eMutateTokenEnv, e2eMutateTokenFile, e2eMutateOpenPR = "E2E_MUTATE_TEST_TOKEN", "", false

View file

@ -16,7 +16,7 @@ import (
) )
const ( const (
fixtureOwner = "test-org-2" fixtureOwner = "Maidn"
fixturePrefix = "maidn-e2e-" fixturePrefix = "maidn-e2e-"
maxBodyBytes = 1 << 20 maxBodyBytes = 1 << 20
) )
@ -78,7 +78,7 @@ func (o Options) Validate() error {
return err return err
} }
if o.Owner != fixtureOwner { if o.Owner != fixtureOwner {
return errors.New("Forgejo mutation owner must be test-org-2") return errors.New("Forgejo mutation owner must be Maidn")
} }
for _, value := range []string{o.Repo, o.Branch} { for _, value := range []string{o.Repo, o.Branch} {
if !fixtureName(value) { if !fixtureName(value) {

View file

@ -27,7 +27,7 @@ func mutationResponse(status int, body string) *http.Response {
func testOptions() Options { func testOptions() Options {
return Options{ return Options{
ForgejoURL: "https://git.example.test", ForgejoURL: "https://git.example.test",
Owner: "test-org-2", Owner: "Maidn",
Repo: "maidn-e2e-repo", Repo: "maidn-e2e-repo",
Branch: "maidn-e2e-branch", Branch: "maidn-e2e-branch",
SHA: "0123456789abcdef0123456789abcdef01234567", SHA: "0123456789abcdef0123456789abcdef01234567",
@ -60,7 +60,7 @@ func TestMutatorUpdatesFixtureRefAndEnsuresOnePR(t *testing.T) {
t.Fatal("mutation request did not authenticate at the API boundary") t.Fatal("mutation request did not authenticate at the API boundary")
} }
switch { switch {
case request.Method == http.MethodPatch && request.URL.Path == "/api/v1/repos/test-org-2/maidn-e2e-repo/git/refs/heads/maidn-e2e-branch": case request.Method == http.MethodPatch && request.URL.Path == "/api/v1/repos/Maidn/maidn-e2e-repo/git/refs/heads/maidn-e2e-branch":
var body struct { var body struct {
SHA string `json:"sha"` SHA string `json:"sha"`
Force bool `json:"force"` Force bool `json:"force"`
@ -69,12 +69,12 @@ func TestMutatorUpdatesFixtureRefAndEnsuresOnePR(t *testing.T) {
t.Fatalf("unexpected branch update: %#v, %v", body, err) t.Fatalf("unexpected branch update: %#v, %v", body, err)
} }
return mutationResponse(http.StatusOK, ""), nil return mutationResponse(http.StatusOK, ""), nil
case request.Method == http.MethodGet && request.URL.Path == "/api/v1/repos/test-org-2/maidn-e2e-repo/pulls": case request.Method == http.MethodGet && request.URL.Path == "/api/v1/repos/Maidn/maidn-e2e-repo/pulls":
if request.URL.Query().Get("head") != "test-org-2:maidn-e2e-branch" || request.URL.Query().Get("state") != "open" { if request.URL.Query().Get("head") != "Maidn:maidn-e2e-branch" || request.URL.Query().Get("state") != "open" {
t.Fatal("pull request lookup did not target the fixture branch") t.Fatal("pull request lookup did not target the fixture branch")
} }
return mutationResponse(http.StatusOK, "[]"), nil return mutationResponse(http.StatusOK, "[]"), nil
case request.Method == http.MethodPost && request.URL.Path == "/api/v1/repos/test-org-2/maidn-e2e-repo/pulls": case request.Method == http.MethodPost && request.URL.Path == "/api/v1/repos/Maidn/maidn-e2e-repo/pulls":
var body struct { var body struct {
Head string `json:"head"` Head string `json:"head"`
Base string `json:"base"` Base string `json:"base"`
@ -101,7 +101,7 @@ func TestMutatorCreatesFixtureRefWhenAbsent(t *testing.T) {
case http.MethodPatch: case http.MethodPatch:
return mutationResponse(http.StatusNotFound, ""), nil return mutationResponse(http.StatusNotFound, ""), nil
case http.MethodPost: case http.MethodPost:
if request.URL.Path != "/api/v1/repos/test-org-2/maidn-e2e-repo/git/refs" { if request.URL.Path != "/api/v1/repos/Maidn/maidn-e2e-repo/git/refs" {
t.Fatalf("branch creation targeted %q", request.URL.Path) t.Fatalf("branch creation targeted %q", request.URL.Path)
} }
return mutationResponse(http.StatusCreated, ""), nil return mutationResponse(http.StatusCreated, ""), nil