From e4319991644229aa7c41a631ce74b5ff81ebcf27 Mon Sep 17 00:00:00 2001 From: Dmitry Makovey Date: Mon, 19 Sep 2022 09:36:27 -0600 Subject: [PATCH 01/15] feat: add notes to the output feat: add MR json output feat: add JSON list of issues feat: make mr list output JSON-capable feat: add pipeline listing JSON output feat: add variable list in JSON format feat: add variable in JSON format feat: Add JSON list to labels feat: Add JSON list to project feat: Add JSON view to project feat: Add JSON test for ci get --- commands/ci/get/get.go | 8 ++-- commands/ci/get/get_test.go | 56 +++++++++++++++++++++---- commands/ci/list/list.go | 13 +++++- commands/issuable/list/issuable_list.go | 11 ++++- commands/issuable/view/issuable_view.go | 24 +++++++++++ commands/label/list/label_list.go | 26 ++++++++---- commands/mr/list/mr_list.go | 26 +++++++++--- commands/mr/view/mr_view.go | 24 +++++++++++ commands/project/list/list.go | 27 ++++++++---- commands/project/view/project_view.go | 36 ++++++++++------ commands/variable/get/get.go | 22 ++++++++-- commands/variable/list/list.go | 32 ++++++++++---- docs/source/ci/get.md | 2 +- docs/source/ci/list.md | 11 ++--- docs/source/incident/list.md | 2 +- docs/source/incident/view.md | 11 ++--- docs/source/issue/list.md | 2 +- docs/source/issue/view.md | 11 ++--- docs/source/label/list.md | 5 ++- docs/source/mr/list.md | 1 + docs/source/mr/view.md | 11 ++--- docs/source/repo/list.md | 19 +++++---- docs/source/repo/view.md | 5 ++- docs/source/variable/get.md | 5 ++- docs/source/variable/list.md | 5 ++- pkg/httpmock/stub.go | 2 + 26 files changed, 297 insertions(+), 100 deletions(-) diff --git a/commands/ci/get/get.go b/commands/ci/get/get.go index a774c9eec..5725b38d4 100644 --- a/commands/ci/get/get.go +++ b/commands/ci/get/get.go @@ -96,7 +96,7 @@ func NewCmdGet(f *cmdutils.Factory) *cobra.Command { outputFormat, _ := cmd.Flags().GetString("output-format") if outputFormat == "json" { - printJSON(*mergedPipelineObject) + printJSON(*mergedPipelineObject, f.IO.StdOut) } else { showJobDetails, _ := cmd.Flags().GetBool("with-job-details") printTable(*mergedPipelineObject, f.IO.StdOut, showJobDetails) @@ -108,16 +108,16 @@ func NewCmdGet(f *cmdutils.Factory) *cobra.Command { pipelineGetCmd.Flags().StringP("branch", "b", "", "Check pipeline status for a branch. (Default is current branch)") pipelineGetCmd.Flags().IntP("pipeline-id", "p", 0, "Provide pipeline ID") - pipelineGetCmd.Flags().StringP("output-format", "o", "text", "Format output as: text, json") + pipelineGetCmd.Flags().StringP("output-format", "F", "text", "Format output as: text, json") pipelineGetCmd.Flags().BoolP("with-job-details", "d", false, "Show extended job information") pipelineGetCmd.Flags().Bool("with-variables", false, "Show variables in pipeline (maintainer role required)") return pipelineGetCmd } -func printJSON(p PipelineMergedResponse) { +func printJSON(p PipelineMergedResponse, dest io.Writer) { JSONStr, _ := json.Marshal(p) - fmt.Println(string(JSONStr)) + fmt.Fprintln(dest, string(JSONStr)) } func printTable(p PipelineMergedResponse, dest io.Writer, showJobDetails bool) { diff --git a/commands/ci/get/get_test.go b/commands/ci/get/get_test.go index 4f894e931..e96df2b10 100644 --- a/commands/ci/get/get_test.go +++ b/commands/ci/get/get_test.go @@ -1,7 +1,9 @@ package status import ( + "fmt" "net/http" + "os" "testing" "gitlab.com/gitlab-org/cli/commands/cmdtest" @@ -24,19 +26,24 @@ func runCommand(rt http.RoundTripper, isTTY bool, args string) (*test.CmdOut, er return cmdtest.ExecuteCommand(cmd, args, stdout, stderr) } +const FILE_BODY = 1 +const INLINE_BODY = 2 + func TestCIGet(t *testing.T) { type httpMock struct { - method string - path string - status int - body string + method string + path string + status int + body string + bodyType int } tests := []struct { - name string - args string - httpMocks []httpMock - expectedOut string + name string + args string + httpMocks []httpMock + expectedOut string + expectedOutType int }{ { name: "when get is called on an existing pipeline", @@ -61,12 +68,14 @@ func TestCIGet(t *testing.T) { "started_at": "2023-10-10T00:00:00Z", "updated_at": "2023-10-10T00:00:00Z" }`, + INLINE_BODY, }, { http.MethodGet, "/api/v4/projects/OWNER%2FREPO/pipelines/123/jobs?per_page=100", http.StatusOK, `[]`, + INLINE_BODY, }, }, expectedOut: `# Pipeline: @@ -276,12 +285,14 @@ ID Name Status Duration Failure reason "started_at": "2023-10-10T00:00:00Z", "updated_at": "2023-10-10T00:00:00Z" }`, + INLINE_BODY, }, { http.MethodGet, "/api/v4/projects/OWNER%2FREPO/pipelines/123/jobs?per_page=100", http.StatusOK, `[]`, + INLINE_BODY, }, { http.MethodGet, @@ -292,6 +303,7 @@ ID Name Status Duration Failure reason "variable_type": "env_var", "value": "true" }]`, + INLINE_BODY, }, }, expectedOut: `# Pipeline: @@ -338,18 +350,21 @@ RUN_NIGHTLY_BUILD: true "started_at": "2023-10-10T00:00:00Z", "updated_at": "2023-10-10T00:00:00Z" }`, + INLINE_BODY, }, { http.MethodGet, "/api/v4/projects/OWNER%2FREPO/pipelines/123/jobs?per_page=100", http.StatusOK, `[]`, + INLINE_BODY, }, { http.MethodGet, "/api/v4/projects/5/pipelines/123/variables", http.StatusOK, "[]", + INLINE_BODY, }, }, expectedOut: `# Pipeline: @@ -371,6 +386,28 @@ updated: 2023-10-10 00:00:00 +0000 UTC No variables found in pipeline. `, }, + { + name: "when requesting output as JSON", + args: "-p 452959326 -F json -b main", + httpMocks: []httpMock{ + { + http.MethodGet, + "/api/v4/projects/OWNER%2FREPO/pipelines/452959326", + http.StatusOK, + "testdata/ci_get-1.json", + FILE_BODY, + }, + { + http.MethodGet, + "/api/v4/projects/OWNER%2FREPO/pipelines/452959326/jobs?per_page=100", + http.StatusOK, + "testdata/ci_get-2.json", + FILE_BODY, + }, + }, + expectedOut: "testdata/ci_get.result", + expectedOutType: FILE_BODY, + }, } for _, tc := range tests { @@ -387,6 +424,9 @@ No variables found in pipeline. output, err := runCommand(fakeHTTP, false, tc.args) require.Nil(t, err) + fmt.Printf("++>> %s\n", output.String()) + os.WriteFile("/tmp/expected", []byte(tc.expectedOut), 0644) + os.WriteFile("/tmp/received", []byte(output.String()), 0644) assert.Equal(t, tc.expectedOut, output.String()) assert.Empty(t, output.Stderr()) }) diff --git a/commands/ci/list/list.go b/commands/ci/list/list.go index f28aff70a..6718aaea2 100644 --- a/commands/ci/list/list.go +++ b/commands/ci/list/list.go @@ -1,6 +1,7 @@ package list import ( + "encoding/json" "fmt" "gitlab.com/gitlab-org/cli/api" @@ -38,6 +39,10 @@ func NewCmdList(f *cmdutils.Factory) *cobra.Command { } l := &gitlab.ListProjectPipelinesOptions{} + + format, _ := cmd.Flags().GetString("output-format") + jsonOut := format == "json" + l.Page = 1 l.PerPage = 30 @@ -68,7 +73,12 @@ func NewCmdList(f *cmdutils.Factory) *cobra.Command { title.Page = l.Page title.CurrentPageTotal = len(pipes) - fmt.Fprintf(f.IO.StdOut, "%s\n%s\n", title.Describe(), ciutils.DisplayMultiplePipelines(f.IO, pipes, repo.FullName())) + if jsonOut { + pipeListJSON, _ := json.Marshal(pipes) + fmt.Fprintln(f.IO.StdOut, string(pipeListJSON)) + } else { + fmt.Fprintf(f.IO.StdOut, "%s\n%s\n", title.Describe(), ciutils.DisplayMultiplePipelines(f.IO, pipes, repo.FullName())) + } return nil }, } @@ -77,6 +87,7 @@ func NewCmdList(f *cmdutils.Factory) *cobra.Command { pipelineListCmd.Flags().StringP("sort", "", "desc", "Sort pipeline by {asc|desc}") pipelineListCmd.Flags().IntP("page", "p", 1, "Page number") pipelineListCmd.Flags().IntP("per-page", "P", 30, "Number of items to list per page") + pipelineListCmd.Flags().StringP("output-format", "F", "text", "Format output as: text, json") return pipelineListCmd } diff --git a/commands/issuable/list/issuable_list.go b/commands/issuable/list/issuable_list.go index 652b1748b..c25c7d80f 100644 --- a/commands/issuable/list/issuable_list.go +++ b/commands/issuable/list/issuable_list.go @@ -1,6 +1,7 @@ package list import ( + "encoding/json" "errors" "fmt" @@ -56,6 +57,8 @@ type ListOptions struct { IO *iostreams.IOStreams BaseRepo func() (glrepo.Interface, error) HTTPClient func() (*gitlab.Client, error) + + JSONOutput bool } func NewCmdList(f *cmdutils.Factory, runE func(opts *ListOptions) error, issueType issuable.IssueType) *cobra.Command { @@ -135,7 +138,7 @@ func NewCmdList(f *cmdutils.Factory, runE func(opts *ListOptions) error, issueTy issueListCmd.Flags().BoolVarP(&opts.All, "all", "A", false, fmt.Sprintf("Get all %ss", issueType)) issueListCmd.Flags().BoolVarP(&opts.Closed, "closed", "c", false, fmt.Sprintf("Get only closed %ss", issueType)) issueListCmd.Flags().BoolVarP(&opts.Confidential, "confidential", "C", false, fmt.Sprintf("Filter by confidential %ss", issueType)) - issueListCmd.Flags().StringVarP(&opts.OutputFormat, "output-format", "F", "details", "One of 'details', 'ids', or 'urls'") + issueListCmd.Flags().StringVarP(&opts.OutputFormat, "output-format", "F", "details", "One of 'details', 'ids', 'urls' or 'json'") issueListCmd.Flags().IntVarP(&opts.Page, "page", "p", 1, "Page number") issueListCmd.Flags().IntVarP(&opts.PerPage, "per-page", "P", 30, "Number of items to list per page.") issueListCmd.PersistentFlags().StringP("group", "g", "", "Select a group/subgroup. This option is ignored if a repo argument is set.") @@ -260,6 +263,12 @@ func listRun(opts *ListOptions) error { title.ListActionType = opts.ListType title.CurrentPageTotal = len(issues) + if opts.OutputFormat == "json" { + issueListJSON, _ := json.Marshal(issues) + fmt.Fprintln(opts.IO.StdOut, string(issueListJSON)) + return nil + } + if opts.OutputFormat == "ids" { for _, i := range issues { fmt.Fprintf(opts.IO.StdOut, "%d\n", i.IID) diff --git a/commands/issuable/view/issuable_view.go b/commands/issuable/view/issuable_view.go index c5bfe9eb7..4fff440d7 100644 --- a/commands/issuable/view/issuable_view.go +++ b/commands/issuable/view/issuable_view.go @@ -1,6 +1,7 @@ package view import ( + "encoding/json" "fmt" "strings" @@ -18,11 +19,17 @@ import ( "github.com/xanzy/go-gitlab" ) +type IssueWithNotes struct { + *gitlab.Issue + Notes []*gitlab.Note +} + type ViewOpts struct { ShowComments bool ShowSystemLogs bool OpenInBrowser bool Web bool + OutputFormat string CommentPageNumber int CommentLimit int @@ -109,6 +116,9 @@ func NewCmdView(f *cmdutils.Factory, issueType issuable.IssueType) *cobra.Comman return err } defer f.IO.StopPager() + if opts.OutputFormat == "json" { + return printJSONIssue(opts) + } if f.IO.IsErrTTY && f.IO.IsaTTY { return printTTYIssuePreview(opts) } @@ -121,6 +131,7 @@ func NewCmdView(f *cmdutils.Factory, issueType issuable.IssueType) *cobra.Comman issueViewCmd.Flags().BoolVarP(&opts.Web, "web", "w", false, fmt.Sprintf("Open %s in a browser. Uses default browser or browser specified in BROWSER variable", issueType)) issueViewCmd.Flags().IntVarP(&opts.CommentPageNumber, "page", "p", 1, "Page number") issueViewCmd.Flags().IntVarP(&opts.CommentLimit, "per-page", "P", 20, "Number of items to list per page") + issueViewCmd.Flags().StringVarP(&opts.OutputFormat, "output-format", "F", "text", "Format output as: text, json") return issueViewCmd } @@ -275,3 +286,16 @@ func RawIssuableNotes(notes []*gitlab.Note, showComments bool, showSystemLogs bo return out } + +func printJSONIssue(opts *ViewOpts) error { + // var notes []gitlab.Note + if opts.ShowComments { + extendedIssue := IssueWithNotes{opts.Issue, opts.Notes} + issueJSON, _ := json.Marshal(extendedIssue) + fmt.Fprintln(opts.IO.StdOut, string(issueJSON)) + } else { + issueJSON, _ := json.Marshal(opts.Issue) + fmt.Fprintln(opts.IO.StdOut, string(issueJSON)) + } + return nil +} diff --git a/commands/label/list/label_list.go b/commands/label/list/label_list.go index 3ebb2e253..63c4c6c2d 100644 --- a/commands/label/list/label_list.go +++ b/commands/label/list/label_list.go @@ -1,6 +1,7 @@ package list import ( + "encoding/json" "fmt" "github.com/MakeNowJust/heredoc" @@ -13,6 +14,8 @@ import ( "github.com/xanzy/go-gitlab" ) +var OutputFormat string + func NewCmdList(f *cmdutils.Factory) *cobra.Command { labelListCmd := &cobra.Command{ Use: "list [flags]", @@ -54,16 +57,22 @@ func NewCmdList(f *cmdutils.Factory) *cobra.Command { if err != nil { return err } - fmt.Fprintf(f.IO.StdOut, "Showing label %d of %d on %s\n\n", len(labels), len(labels), repo.FullName()) - var labelPrintInfo string - for _, label := range labels { - var description string - if label.Description != "" { - description = fmt.Sprintf(" -> %s", label.Description) + if OutputFormat == "json" { + labelListJSON, _ := json.Marshal(labels) + fmt.Fprintln(f.IO.StdOut, string(labelListJSON)) + + } else { + fmt.Fprintf(f.IO.StdOut, "Showing label %d of %d on %s\n\n", len(labels), len(labels), repo.FullName()) + var labelPrintInfo string + for _, label := range labels { + var description string + if label.Description != "" { + description = fmt.Sprintf(" -> %s", label.Description) + } + labelPrintInfo += fmt.Sprintf("%s%s (%s)\n", label.Name, description, label.Color) } - labelPrintInfo += fmt.Sprintf("%s%s (%s)\n", label.Name, description, label.Color) + fmt.Fprintln(f.IO.StdOut, utils.Indent(labelPrintInfo, " ")) } - fmt.Fprintln(f.IO.StdOut, utils.Indent(labelPrintInfo, " ")) // Cache labels for host //labelNames := make([]string, 0, len(labels)) @@ -81,6 +90,7 @@ func NewCmdList(f *cmdutils.Factory) *cobra.Command { labelListCmd.Flags().IntP("page", "p", 1, "Page number") labelListCmd.Flags().IntP("per-page", "P", 30, "Number of items to list per page") + labelListCmd.Flags().StringVarP(&OutputFormat, "output-format", "F", "text", "Format output as: text, json") return labelListCmd } diff --git a/commands/mr/list/mr_list.go b/commands/mr/list/mr_list.go index 5233c42d0..fbb608584 100644 --- a/commands/mr/list/mr_list.go +++ b/commands/mr/list/mr_list.go @@ -1,6 +1,7 @@ package list import ( + "encoding/json" "errors" "fmt" @@ -41,8 +42,9 @@ type ListOptions struct { Draft bool // Pagination - Page int - PerPage int + Page int + PerPage int + OutputFormat string // display opts ListType string @@ -132,12 +134,13 @@ func NewCmdList(f *cmdutils.Factory, runE func(opts *ListOptions) error) *cobra. mrListCmd.Flags().BoolVarP(&opts.Closed, "closed", "c", false, "Get only closed merge requests") mrListCmd.Flags().BoolVarP(&opts.Merged, "merged", "M", false, "Get only merged merge requests") mrListCmd.Flags().BoolVarP(&opts.Draft, "draft", "d", false, "Filter by draft merge requests") + mrListCmd.Flags().StringVarP(&opts.OutputFormat, "output-format", "F", "text", "Format output as: text, json") mrListCmd.Flags().IntVarP(&opts.Page, "page", "p", 1, "Page number") mrListCmd.Flags().IntVarP(&opts.PerPage, "per-page", "P", 30, "Number of items to list per page") mrListCmd.Flags().StringSliceVarP(&opts.Assignee, "assignee", "a", []string{}, "Get only merge requests assigned to users") mrListCmd.Flags().StringSliceVarP(&opts.Reviewer, "reviewer", "r", []string{}, "Get only merge requests with users as reviewer") - mrListCmd.Flags().BoolP("opened", "o", false, "Get only open merge requests") + mrListCmd.Flags().BoolP("opened", "O", false, "Get only open merge requests") _ = mrListCmd.Flags().MarkHidden("opened") _ = mrListCmd.Flags().MarkDeprecated("opened", "default value if neither --closed, --locked or --merged is used") @@ -165,8 +168,14 @@ func listRun(opts *ListOptions) error { l := &gitlab.ListProjectMergeRequestsOptions{ State: gitlab.String(opts.State), } - l.Page = 1 - l.PerPage = 30 + jsonOutput := opts.OutputFormat == "json" + if jsonOutput { + l.Page = 0 + l.PerPage = 0 + } else { + l.Page = 1 + l.PerPage = 30 + } if opts.Author != "" { u, err := api.UserByName(apiClient, opts.Author) @@ -260,7 +269,12 @@ func listRun(opts *ListOptions) error { return err } defer opts.IO.StopPager() - fmt.Fprintf(opts.IO.StdOut, "%s\n%s\n", title.Describe(), mrutils.DisplayAllMRs(opts.IO, mergeRequests)) + if jsonOutput { + mrListJSON, _ := json.Marshal(mergeRequests) + fmt.Fprintln(opts.IO.StdOut, string(mrListJSON)) + } else { + fmt.Fprintf(opts.IO.StdOut, "%s\n%s\n", title.Describe(), mrutils.DisplayAllMRs(opts.IO, mergeRequests)) + } return nil } diff --git a/commands/mr/view/mr_view.go b/commands/mr/view/mr_view.go index 8f9c31f86..bbfe18172 100644 --- a/commands/mr/view/mr_view.go +++ b/commands/mr/view/mr_view.go @@ -1,6 +1,7 @@ package view import ( + "encoding/json" "fmt" "strings" @@ -21,6 +22,7 @@ type ViewOpts struct { ShowComments bool ShowSystemLogs bool OpenInBrowser bool + OutputFormat string CommentPageNumber int CommentLimit int @@ -28,6 +30,11 @@ type ViewOpts struct { IO *iostreams.IOStreams } +type MRWithNotes struct { + *gitlab.MergeRequest + Notes []*gitlab.Note +} + func NewCmdView(f *cmdutils.Factory) *cobra.Command { opts := &ViewOpts{ IO: f.IO, @@ -96,6 +103,9 @@ func NewCmdView(f *cmdutils.Factory) *cobra.Command { } defer f.IO.StopPager() + if opts.OutputFormat == "json" { + return printJSONMR(opts, mr, notes) + } if f.IO.IsOutputTTY() { return printTTYMRPreview(opts, mr, mrApprovals, notes) } @@ -105,6 +115,7 @@ func NewCmdView(f *cmdutils.Factory) *cobra.Command { mrViewCmd.Flags().BoolVarP(&opts.ShowComments, "comments", "c", false, "Show mr comments and activities") mrViewCmd.Flags().BoolVarP(&opts.ShowSystemLogs, "system-logs", "s", false, "Show system activities / logs") + mrViewCmd.Flags().StringVarP(&opts.OutputFormat, "output-format", "F", "text", "Format output as: text, json") mrViewCmd.Flags().BoolVarP(&opts.OpenInBrowser, "web", "w", false, "Open mr in a browser. Uses default browser or browser specified in BROWSER variable") mrViewCmd.Flags().IntVarP(&opts.CommentPageNumber, "page", "p", 0, "Page number") mrViewCmd.Flags().IntVarP(&opts.CommentLimit, "per-page", "P", 20, "Number of items to list per page") @@ -281,3 +292,16 @@ func rawMRPreview(opts *ViewOpts, mr *gitlab.MergeRequest, notes []*gitlab.Note) return out } + +func printJSONMR(opts *ViewOpts, mr *gitlab.MergeRequest, notes []*gitlab.Note) error { + // var notes []gitlab.Note + if opts.ShowComments { + extendedMR := MRWithNotes{mr, notes} + mrJSON, _ := json.Marshal(extendedMR) + fmt.Fprintln(opts.IO.StdOut, string(mrJSON)) + } else { + mrJSON, _ := json.Marshal(mr) + fmt.Fprintln(opts.IO.StdOut, string(mrJSON)) + } + return nil +} diff --git a/commands/project/list/list.go b/commands/project/list/list.go index b5507aa74..947b03729 100644 --- a/commands/project/list/list.go +++ b/commands/project/list/list.go @@ -1,6 +1,7 @@ package list import ( + "encoding/json" "fmt" "gitlab.com/gitlab-org/cli/pkg/iostreams" @@ -18,6 +19,7 @@ type Options struct { Group string PerPage int Page int + OutputFormat string FilterAll bool FilterOwned bool FilterMember bool @@ -51,6 +53,7 @@ func NewCmdList(f *cmdutils.Factory) *cobra.Command { repoListCmd.Flags().StringVarP(&opts.Group, "group", "g", "", "Return only repositories in the given group and its subgroups") repoListCmd.Flags().IntVarP(&opts.Page, "page", "p", 1, "Page number") repoListCmd.Flags().IntVarP(&opts.PerPage, "per-page", "P", 30, "Number of items to list per page") + repoListCmd.Flags().StringVarP(&opts.OutputFormat, "output-format", "F", "text", "Format output as: text, json") repoListCmd.Flags().BoolVarP(&opts.FilterAll, "all", "a", false, "List all projects on the instance") repoListCmd.Flags().BoolVarP(&opts.FilterOwned, "mine", "m", false, "Only list projects you own (default if no filters are passed)") repoListCmd.Flags().BoolVar(&opts.FilterMember, "member", false, "Only list projects which you are a member") @@ -79,17 +82,25 @@ func runE(opts *Options) error { return err } - title := fmt.Sprintf("Showing %d of %d projects (Page %d of %d)\n", len(projects), resp.TotalItems, resp.CurrentPage, resp.TotalPages) + if opts.OutputFormat == "json" { + projectListJSON, _ := json.Marshal(projects) + fmt.Fprintln(opts.IO.StdOut, string(projectListJSON)) + } else { + // Title + title := fmt.Sprintf("Showing %d of %d projects (Page %d of %d)\n", len(projects), resp.TotalItems, resp.CurrentPage, resp.TotalPages) + + // List + table := tableprinter.NewTablePrinter() + for _, prj := range projects { + table.AddCell(c.Blue(prj.PathWithNamespace)) + table.AddCell(prj.SSHURLToRepo) + table.AddCell(prj.Description) + table.EndRow() + } - table := tableprinter.NewTablePrinter() - for _, prj := range projects { - table.AddCell(c.Blue(prj.PathWithNamespace)) - table.AddCell(prj.SSHURLToRepo) - table.AddCell(prj.Description) - table.EndRow() + fmt.Fprintf(opts.IO.StdOut, "%s\n%s\n", title, table.String()) } - fmt.Fprintf(opts.IO.StdOut, "%s\n%s\n", title, table.String()) return err } diff --git a/commands/project/view/project_view.go b/commands/project/view/project_view.go index 69bd12a47..d4d55c82a 100644 --- a/commands/project/view/project_view.go +++ b/commands/project/view/project_view.go @@ -2,6 +2,7 @@ package view import ( "encoding/base64" + "encoding/json" "fmt" "net/url" "strings" @@ -20,6 +21,7 @@ type ViewOptions struct { ProjectID string APIClient *gitlab.Client Web bool + OutputFormat string Branch string Browser string GlamourStyle string @@ -120,6 +122,7 @@ func NewCmdView(f *cmdutils.Factory) *cobra.Command { } projectViewCmd.Flags().BoolVarP(&opts.Web, "web", "w", false, "Open a project in the browser") + projectViewCmd.Flags().StringVarP(&opts.OutputFormat, "output-format", "F", "text", "Format output as: text, json") projectViewCmd.Flags().StringVarP(&opts.Branch, "branch", "b", "", "View a specific branch of the repository") return projectViewCmd @@ -146,22 +149,24 @@ func runViewProject(opts *ViewOptions) error { generateProjectOpenURL(projectURL, project.DefaultBranch, opts.Branch), opts.Browser, ) - } - - readmeFile, err := getReadmeFile(opts, project) - if err != nil { - return err - } - - if opts.IO.IsaTTY { - if err := opts.IO.StartPager(); err != nil { + } else if opts.OutputFormat == "json" { + printProjectContentJSON(opts, project) + } else { + readmeFile, err := getReadmeFile(opts, project) + if err != nil { return err } - defer opts.IO.StopPager() - printProjectContentTTY(opts, project, readmeFile) - } else { - printProjectContentRaw(opts, project, readmeFile) + if opts.IO.IsaTTY { + if err := opts.IO.StartPager(); err != nil { + return err + } + defer opts.IO.StopPager() + + printProjectContentTTY(opts, project, readmeFile) + } else { + printProjectContentRaw(opts, project, readmeFile) + } } return nil @@ -257,3 +262,8 @@ func printProjectContentRaw(opts *ViewOptions, project *gitlab.Project, readme * fmt.Fprintln(opts.IO.StdOut) } } + +func printProjectContentJSON(opts *ViewOptions, project *gitlab.Project) { + projectJSON, _ := json.Marshal(project) + fmt.Fprintln(opts.IO.StdOut, string(projectJSON)) +} diff --git a/commands/variable/get/get.go b/commands/variable/get/get.go index 47d6e5635..c2a9d9116 100644 --- a/commands/variable/get/get.go +++ b/commands/variable/get/get.go @@ -1,6 +1,7 @@ package get import ( + "encoding/json" "errors" "fmt" @@ -19,9 +20,11 @@ type GetOps struct { IO *iostreams.IOStreams BaseRepo func() (glrepo.Interface, error) - Key string - Group string - Scope string + Scope string + Key string + Group string + OutputFormat string + JSONOutput bool } func NewCmdSet(f *cmdutils.Factory, runE func(opts *GetOps) error) *cobra.Command { @@ -65,6 +68,7 @@ func NewCmdSet(f *cmdutils.Factory, runE func(opts *GetOps) error) *cobra.Comman cmd.Flags().StringVarP(&opts.Scope, "scope", "s", "*", "The environment_scope of the variable. All (*), or specific environments.") cmd.Flags().StringVarP(&opts.Group, "group", "g", "", "Get variable for a group") + cmd.Flags().StringVarP(&opts.OutputFormat, "output-format", "F", "text", "Format output as: text, json") return cmd } @@ -81,6 +85,10 @@ func getRun(opts *GetOps) error { if err != nil { return err } + if opts.OutputFormat == "json" { + varJSON, _ := json.Marshal(variable) + fmt.Println(string(varJSON)) + } variableValue = variable.Value } else { baseRepo, err := opts.BaseRepo() @@ -92,9 +100,15 @@ func getRun(opts *GetOps) error { if err != nil { return err } + if opts.OutputFormat == "json" { + varJSON, _ := json.Marshal(variable) + fmt.Fprintln(opts.IO.StdOut, string(varJSON)) + } variableValue = variable.Value } - fmt.Fprint(opts.IO.StdOut, variableValue) + if opts.OutputFormat != "json" { + fmt.Fprint(opts.IO.StdOut, variableValue) + } return nil } diff --git a/commands/variable/list/list.go b/commands/variable/list/list.go index 4ae0a3481..f738e7e7a 100644 --- a/commands/variable/list/list.go +++ b/commands/variable/list/list.go @@ -1,6 +1,9 @@ package list import ( + "encoding/json" + "fmt" + "github.com/MakeNowJust/heredoc" "github.com/spf13/cobra" "github.com/xanzy/go-gitlab" @@ -18,8 +21,9 @@ type ListOpts struct { IO *iostreams.IOStreams BaseRepo func() (glrepo.Interface, error) - ValueSet bool - Group string + ValueSet bool + Group string + OutputFormat string } func NewCmdSet(f *cmdutils.Factory, runE func(opts *ListOpts) error) *cobra.Command { @@ -64,6 +68,7 @@ func NewCmdSet(f *cmdutils.Factory, runE func(opts *ListOpts) error) *cobra.Comm "", "Select a group/subgroup. This option is ignored if a repo argument is set.", ) + cmd.Flags().StringVarP(&opts.OutputFormat, "output-format", "F", "text", "Format output as: text, json") return cmd } @@ -90,8 +95,14 @@ func listRun(opts *ListOpts) error { if err != nil { return err } - for _, variable := range variables { - table.AddRow(variable.Key, variable.Protected, variable.Masked, !variable.Raw, variable.EnvironmentScope) + if opts.OutputFormat == "json" { + varListJSON, _ := json.Marshal(variables) + fmt.Fprintln(opts.IO.StdOut, string(varListJSON)) + + } else { + for _, variable := range variables { + table.AddRow(variable.Key, variable.Protected, variable.Masked, !variable.Raw, variable.EnvironmentScope) + } } } else { opts.IO.Logf("Listing variables for the %s project:\n\n", color.Bold(repo.FullName())) @@ -100,11 +111,18 @@ func listRun(opts *ListOpts) error { if err != nil { return err } - for _, variable := range variables { - table.AddRow(variable.Key, variable.Protected, variable.Masked, !variable.Raw, variable.EnvironmentScope) + if opts.OutputFormat == "json" { + varListJSON, _ := json.Marshal(variables) + fmt.Fprintln(opts.IO.StdOut, string(varListJSON)) + } else { + for _, variable := range variables { + table.AddRow(variable.Key, variable.Protected, variable.Masked, !variable.Raw, variable.EnvironmentScope) + } } } - opts.IO.Log(table.String()) + if opts.OutputFormat != "json" { + opts.IO.Log(table.String()) + } return nil } diff --git a/docs/source/ci/get.md b/docs/source/ci/get.md index b024b0707..d3af706fe 100644 --- a/docs/source/ci/get.md +++ b/docs/source/ci/get.md @@ -35,7 +35,7 @@ glab ci -R some/project -p 12345 ```plaintext -b, --branch string Check pipeline status for a branch. (Default is current branch) - -o, --output-format string Format output as: text, json (default "text") + -F, --output-format string Format output as: text, json (default "text") -p, --pipeline-id int Provide pipeline ID -d, --with-job-details Show extended job information --with-variables Show variables in pipeline (maintainer role required) diff --git a/docs/source/ci/list.md b/docs/source/ci/list.md index e72c5adc6..0480cf995 100644 --- a/docs/source/ci/list.md +++ b/docs/source/ci/list.md @@ -28,11 +28,12 @@ glab ci list --status=failed ## Options ```plaintext - -o, --orderBy string Order pipeline by {id|status|ref|updated_at|user_id} (default "id") - -p, --page int Page number (default 1) - -P, --per-page int Number of items to list per page (default 30) - --sort string Sort pipeline by {asc|desc} (default "desc") - -s, --status string Get pipeline with status: {running|pending|success|failed|canceled|skipped|created|manual|waiting_for_resource|preparing|scheduled} + -o, --orderBy string Order pipeline by {id|status|ref|updated_at|user_id} (default "id") + -F, --output-format string Format output as: text, json (default "text") + -p, --page int Page number (default 1) + -P, --per-page int Number of items to list per page (default 30) + --sort string Sort pipeline by {asc|desc} (default "desc") + -s, --status string Get pipeline with status: {running|pending|success|failed|canceled|skipped|created|manual|waiting_for_resource|preparing|scheduled} ``` ## Options inherited from parent commands diff --git a/docs/source/incident/list.md b/docs/source/incident/list.md index c1bcfa045..6188f7650 100644 --- a/docs/source/incident/list.md +++ b/docs/source/incident/list.md @@ -48,7 +48,7 @@ glab incident list --milestone release-2.0.0 --opened --not-assignee strings Filter incident by not being assigneed to --not-author strings Filter by not being by author(s) --not-label strings Filter incident by lack of label - -F, --output-format string One of 'details', 'ids', or 'urls' (default "details") + -F, --output-format string One of 'details', 'ids', 'urls' or 'json' (default "details") -p, --page int Page number (default 1) -P, --per-page int Number of items to list per page. (default 30) -R, --repo OWNER/REPO Select another repository using the OWNER/REPO or `GROUP/NAMESPACE/REPO` format or full URL or git URL diff --git a/docs/source/incident/view.md b/docs/source/incident/view.md index dac54bfbe..377c12be7 100644 --- a/docs/source/incident/view.md +++ b/docs/source/incident/view.md @@ -37,11 +37,12 @@ glab incident view https://gitlab.com/NAMESPACE/REPO/-/issues/incident/123 ## Options ```plaintext - -c, --comments Show incident comments and activities - -p, --page int Page number (default 1) - -P, --per-page int Number of items to list per page (default 20) - -s, --system-logs Show system activities / logs - -w, --web Open incident in a browser. Uses default browser or browser specified in BROWSER variable + -c, --comments Show incident comments and activities + -F, --output-format string Format output as: text, json (default "text") + -p, --page int Page number (default 1) + -P, --per-page int Number of items to list per page (default 20) + -s, --system-logs Show system activities / logs + -w, --web Open incident in a browser. Uses default browser or browser specified in BROWSER variable ``` ## Options inherited from parent commands diff --git a/docs/source/issue/list.md b/docs/source/issue/list.md index 1cc1abead..ab0e1276a 100644 --- a/docs/source/issue/list.md +++ b/docs/source/issue/list.md @@ -49,7 +49,7 @@ glab issue list --milestone release-2.0.0 --opened --not-assignee strings Filter issue by not being assigneed to --not-author strings Filter by not being by author(s) --not-label strings Filter issue by lack of label - -F, --output-format string One of 'details', 'ids', or 'urls' (default "details") + -F, --output-format string One of 'details', 'ids', 'urls' or 'json' (default "details") -p, --page int Page number (default 1) -P, --per-page int Number of items to list per page. (default 30) -R, --repo OWNER/REPO Select another repository using the OWNER/REPO or `GROUP/NAMESPACE/REPO` format or full URL or git URL diff --git a/docs/source/issue/view.md b/docs/source/issue/view.md index 203013fae..9286b3969 100644 --- a/docs/source/issue/view.md +++ b/docs/source/issue/view.md @@ -37,11 +37,12 @@ glab issue view https://gitlab.com/NAMESPACE/REPO/-/issues/123 ## Options ```plaintext - -c, --comments Show issue comments and activities - -p, --page int Page number (default 1) - -P, --per-page int Number of items to list per page (default 20) - -s, --system-logs Show system activities / logs - -w, --web Open issue in a browser. Uses default browser or browser specified in BROWSER variable + -c, --comments Show issue comments and activities + -F, --output-format string Format output as: text, json (default "text") + -p, --page int Page number (default 1) + -P, --per-page int Number of items to list per page (default 20) + -s, --system-logs Show system activities / logs + -w, --web Open issue in a browser. Uses default browser or browser specified in BROWSER variable ``` ## Options inherited from parent commands diff --git a/docs/source/label/list.md b/docs/source/label/list.md index 8034f6d06..8a254d6bb 100644 --- a/docs/source/label/list.md +++ b/docs/source/label/list.md @@ -35,8 +35,9 @@ glab label list -R owner/repository ## Options ```plaintext - -p, --page int Page number (default 1) - -P, --per-page int Number of items to list per page (default 30) + -F, --output-format string Format output as: text, json (default "text") + -p, --page int Page number (default 1) + -P, --per-page int Number of items to list per page (default 30) ``` ## Options inherited from parent commands diff --git a/docs/source/mr/list.md b/docs/source/mr/list.md index d96787ff0..2b88c057f 100644 --- a/docs/source/mr/list.md +++ b/docs/source/mr/list.md @@ -52,6 +52,7 @@ glab mr list -M --per-page 10 -M, --merged Get only merged merge requests -m, --milestone string Filter merge request by milestone --not-label strings Filter merge requests by not having label + -F, --output-format string Format output as: text, json (default "text") -p, --page int Page number (default 1) -P, --per-page int Number of items to list per page (default 30) -R, --repo OWNER/REPO Select another repository using the OWNER/REPO or `GROUP/NAMESPACE/REPO` format or full URL or git URL diff --git a/docs/source/mr/view.md b/docs/source/mr/view.md index 78752b3f2..1dd61938a 100644 --- a/docs/source/mr/view.md +++ b/docs/source/mr/view.md @@ -26,11 +26,12 @@ show ## Options ```plaintext - -c, --comments Show mr comments and activities - -p, --page int Page number - -P, --per-page int Number of items to list per page (default 20) - -s, --system-logs Show system activities / logs - -w, --web Open mr in a browser. Uses default browser or browser specified in BROWSER variable + -c, --comments Show mr comments and activities + -F, --output-format string Format output as: text, json (default "text") + -p, --page int Page number + -P, --per-page int Number of items to list per page (default 20) + -s, --system-logs Show system activities / logs + -w, --web Open mr in a browser. Uses default browser or browser specified in BROWSER variable ``` ## Options inherited from parent commands diff --git a/docs/source/repo/list.md b/docs/source/repo/list.md index d39efc6e8..cfc73d227 100644 --- a/docs/source/repo/list.md +++ b/docs/source/repo/list.md @@ -33,15 +33,16 @@ glab repo list ## Options ```plaintext - -a, --all List all projects on the instance - -g, --group string Return only repositories in the given group and its subgroups - --member Only list projects which you are a member - -m, --mine Only list projects you own (default if no filters are passed) - -o, --order string Return repositories ordered by id, created_at, or other fields (default "last_activity_at") - -p, --page int Page number (default 1) - -P, --per-page int Number of items to list per page (default 30) - -s, --sort string Return repositories sorted in asc or desc order - --starred Only list starred projects + -a, --all List all projects on the instance + -g, --group string Return only repositories in the given group and its subgroups + --member Only list projects which you are a member + -m, --mine Only list projects you own (default if no filters are passed) + -o, --order string Return repositories ordered by id, created_at, or other fields (default "last_activity_at") + -F, --output-format string Format output as: text, json (default "text") + -p, --page int Page number (default 1) + -P, --per-page int Number of items to list per page (default 30) + -s, --sort string Return repositories sorted in asc or desc order + --starred Only list starred projects ``` ## Options inherited from parent commands diff --git a/docs/source/repo/view.md b/docs/source/repo/view.md index a030fccf5..a15a636f4 100644 --- a/docs/source/repo/view.md +++ b/docs/source/repo/view.md @@ -42,8 +42,9 @@ $ glab repo view https://gitlab.company.org/user/repo.git ## Options ```plaintext - -b, --branch string View a specific branch of the repository - -w, --web Open a project in the browser + -b, --branch string View a specific branch of the repository + -F, --output-format string Format output as: text, json (default "text") + -w, --web Open a project in the browser ``` ## Options inherited from parent commands diff --git a/docs/source/variable/get.md b/docs/source/variable/get.md index d3ff10be7..6b33648c2 100644 --- a/docs/source/variable/get.md +++ b/docs/source/variable/get.md @@ -29,8 +29,9 @@ glab variable get -s SCOPE VAR_KEY ## Options ```plaintext - -g, --group string Get variable for a group - -s, --scope string The environment_scope of the variable. All (*), or specific environments. (default "*") + -g, --group string Get variable for a group + -F, --output-format string Format output as: text, json (default "text") + -s, --scope string The environment_scope of the variable. All (*), or specific environments. (default "*") ``` ## Options inherited from parent commands diff --git a/docs/source/variable/list.md b/docs/source/variable/list.md index bb3640019..11cad4344 100644 --- a/docs/source/variable/list.md +++ b/docs/source/variable/list.md @@ -33,8 +33,9 @@ glab variable list ## Options ```plaintext - -g, --group string Select a group/subgroup. This option is ignored if a repo argument is set. - -R, --repo OWNER/REPO Select another repository using the OWNER/REPO or `GROUP/NAMESPACE/REPO` format or full URL or git URL + -g, --group string Select a group/subgroup. This option is ignored if a repo argument is set. + -F, --output-format string Format output as: text, json (default "text") + -R, --repo OWNER/REPO Select another repository using the OWNER/REPO or `GROUP/NAMESPACE/REPO` format or full URL or git URL ``` ## Options inherited from parent commands diff --git a/pkg/httpmock/stub.go b/pkg/httpmock/stub.go index 7c1725fa8..071ffc05e 100644 --- a/pkg/httpmock/stub.go +++ b/pkg/httpmock/stub.go @@ -3,6 +3,7 @@ package httpmock import ( "bytes" "encoding/json" + "fmt" "io" "net/http" "net/url" @@ -80,6 +81,7 @@ func NewFileResponse(status int, filename string) Responder { } func httpResponse(status int, req *http.Request, body io.Reader) *http.Response { + fmt.Fprintf(os.Stderr, ">> %s\n", req.URL.String()) return &http.Response{ StatusCode: status, Request: req, -- GitLab From 8942c323053a24d32e2e121ffe70d88d6b68b3dd Mon Sep 17 00:00:00 2001 From: Dmitry Makovey Date: Tue, 13 Feb 2024 11:34:06 -0800 Subject: [PATCH 02/15] Add test data --- test/json_output_data/ci_list.json | 195 ++++++++++++++++++ test/json_output_data/ci_list_result.json | 1 + test/json_output_data/issue_list.json | 78 +++++++ test/json_output_data/issue_list_result.json | 1 + test/json_output_data/issue_view.json | 77 +++++++ test/json_output_data/issue_view_result.json | 1 + test/json_output_data/label_list.json | 27 +++ test/json_output_data/label_list_result.json | 1 + test/json_output_data/mr_list.json | 171 +++++++++++++++ test/json_output_data/mr_list_result.json | 1 + test/json_output_data/mr_view.json | 184 +++++++++++++++++ test/json_output_data/mr_view_result.json | 1 + test/json_output_data/project_list.json | 175 ++++++++++++++++ .../json_output_data/project_list_result.json | 1 + test/json_output_data/project_view.json | 188 +++++++++++++++++ .../json_output_data/project_view_result.json | 1 + test/json_output_data/variable_get.json | 21 ++ .../json_output_data/variable_get_result.json | 1 + test/json_output_data/variable_list.json | 23 +++ .../variable_list_result.json | 1 + 20 files changed, 1149 insertions(+) create mode 100644 test/json_output_data/ci_list.json create mode 100644 test/json_output_data/ci_list_result.json create mode 100644 test/json_output_data/issue_list.json create mode 100644 test/json_output_data/issue_list_result.json create mode 100644 test/json_output_data/issue_view.json create mode 100644 test/json_output_data/issue_view_result.json create mode 100644 test/json_output_data/label_list.json create mode 100644 test/json_output_data/label_list_result.json create mode 100644 test/json_output_data/mr_list.json create mode 100644 test/json_output_data/mr_list_result.json create mode 100644 test/json_output_data/mr_view.json create mode 100644 test/json_output_data/mr_view_result.json create mode 100644 test/json_output_data/project_list.json create mode 100644 test/json_output_data/project_list_result.json create mode 100644 test/json_output_data/project_view.json create mode 100644 test/json_output_data/project_view_result.json create mode 100644 test/json_output_data/variable_get.json create mode 100644 test/json_output_data/variable_get_result.json create mode 100644 test/json_output_data/variable_list.json create mode 100644 test/json_output_data/variable_list_result.json diff --git a/test/json_output_data/ci_list.json b/test/json_output_data/ci_list.json new file mode 100644 index 000000000..b768e49f5 --- /dev/null +++ b/test/json_output_data/ci_list.json @@ -0,0 +1,195 @@ +[ + { + "request": { + "url": "/api/v4/projects/OWNER%2FREPO/pipelines?order_by=id&page=1&per_page=30&sort=desc", + "method": "GET" + }, + "response": { + "body": [ + { + "id": 452959326, + "iid": 14, + "project_id": 29316529, + "sha": "44eb489568f7cb1a5a730fce6b247cd3797172ca", + "ref": "1-fake-issue-3", + "status": "success", + "source": "push", + "created_at": "2022-01-20T21:47:16.276Z", + "updated_at": "2022-01-20T21:47:31.358Z", + "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/452959326", + "name": null + }, + { + "id": 452944621, + "iid": 13, + "project_id": 29316529, + "sha": "001eb421e586a3f07f90aea102c8b2d4068ab5b6", + "ref": "1-fake-issue-3", + "status": "success", + "source": "push", + "created_at": "2022-01-20T21:20:50.971Z", + "updated_at": "2022-01-20T21:21:04.802Z", + "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/452944621", + "name": null + }, + { + "id": 452941417, + "iid": 12, + "project_id": 29316529, + "sha": "001eb421e586a3f07f90aea102c8b2d4068ab5b6", + "ref": "1-fake-issue", + "status": "success", + "source": "push", + "created_at": "2022-01-20T21:15:42.546Z", + "updated_at": "2022-01-20T21:15:55.200Z", + "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/452941417", + "name": null + }, + { + "id": 452939664, + "iid": 11, + "project_id": 29316529, + "sha": "001eb421e586a3f07f90aea102c8b2d4068ab5b6", + "ref": "1-mr", + "status": "success", + "source": "push", + "created_at": "2022-01-20T21:12:35.048Z", + "updated_at": "2022-01-20T21:12:50.132Z", + "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/452939664", + "name": null + }, + { + "id": 450719821, + "iid": 10, + "project_id": 29316529, + "sha": "123f34ebfd5d97ef562974e55e01b83f06ae7b4a", + "ref": "OWNER-main-patch-25608", + "status": "success", + "source": "push", + "created_at": "2022-01-18T18:06:49.629Z", + "updated_at": "2022-01-18T18:08:09.708Z", + "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/450719821", + "name": null + }, + { + "id": 450714758, + "iid": 9, + "project_id": 29316529, + "sha": "f288fd8d797a05c2946eb5d675f9d4438a150bec", + "ref": "OWNER-main-patch-25608", + "status": "success", + "source": "push", + "created_at": "2022-01-18T18:04:03.546Z", + "updated_at": "2022-01-18T18:05:23.843Z", + "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/450714758", + "name": null + }, + { + "id": 450707660, + "iid": 8, + "project_id": 29316529, + "sha": "afe2714d50f156567ab87c2434cd901de7d341dc", + "ref": "OWNER-main-patch-25608", + "status": "success", + "source": "push", + "created_at": "2022-01-18T18:00:31.663Z", + "updated_at": "2022-01-18T18:01:53.086Z", + "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/450707660", + "name": null + }, + { + "id": 450615878, + "iid": 7, + "project_id": 29316529, + "sha": "a4030d817a2881f5998e6466b9ba90914aecfb18", + "ref": "OWNER-main-patch-25608", + "status": "success", + "source": "push", + "created_at": "2022-01-18T17:02:16.204Z", + "updated_at": "2022-01-18T17:03:22.021Z", + "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/450615878", + "name": null + }, + { + "id": 364128214, + "iid": 6, + "project_id": 29316529, + "sha": "001eb421e586a3f07f90aea102c8b2d4068ab5b6", + "ref": "main", + "status": "success", + "source": "push", + "created_at": "2021-09-02T14:19:52.731Z", + "updated_at": "2021-09-02T14:20:07.800Z", + "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/364128214", + "name": null + }, + { + "id": 364109593, + "iid": 5, + "project_id": 29316529, + "sha": "2a10724040f892e45917e4aef03cdb821e98bd99", + "ref": "main", + "status": "success", + "source": "web", + "created_at": "2021-09-02T13:58:21.181Z", + "updated_at": "2021-09-02T13:58:35.804Z", + "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/364109593", + "name": null + }, + { + "id": 364109341, + "iid": 4, + "project_id": 29316529, + "sha": "2a10724040f892e45917e4aef03cdb821e98bd99", + "ref": "main", + "status": "success", + "source": "push", + "created_at": "2021-09-02T13:57:59.126Z", + "updated_at": "2021-09-02T13:58:11.734Z", + "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/364109341", + "name": null + }, + { + "id": 364104462, + "iid": 3, + "project_id": 29316529, + "sha": "65fb4980734c4b84fa1f7c934c92f747a6fe3ed0", + "ref": "main", + "status": "success", + "source": "web", + "created_at": "2021-09-02T13:51:43.615Z", + "updated_at": "2021-09-02T13:51:57.057Z", + "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/364104462", + "name": null + }, + { + "id": 364102457, + "iid": 2, + "project_id": 29316529, + "sha": "65fb4980734c4b84fa1f7c934c92f747a6fe3ed0", + "ref": "main", + "status": "success", + "source": "push", + "created_at": "2021-09-02T13:48:58.178Z", + "updated_at": "2021-09-02T13:49:10.689Z", + "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/364102457", + "name": null + }, + { + "id": 364098384, + "iid": 1, + "project_id": 29316529, + "sha": "6bd3a42163672bb5341075021d74231c3d75d4b8", + "ref": "main", + "status": "skipped", + "source": "push", + "created_at": "2021-09-02T13:43:57.758Z", + "updated_at": "2021-09-02T13:43:57.758Z", + "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/364098384", + "name": null + } + ], + "status": 200 + } + } +] diff --git a/test/json_output_data/ci_list_result.json b/test/json_output_data/ci_list_result.json new file mode 100644 index 000000000..423df6ce9 --- /dev/null +++ b/test/json_output_data/ci_list_result.json @@ -0,0 +1 @@ +[{"id":452959326,"iid":14,"project_id":29316529,"status":"success","source":"push","ref":"1-fake-issue-3","sha":"44eb489568f7cb1a5a730fce6b247cd3797172ca","web_url":"https://gitlab.com/OWNER/REPO/-/pipelines/452959326","updated_at":"2022-01-20T21:47:31.358Z","created_at":"2022-01-20T21:47:16.276Z"},{"id":452944621,"iid":13,"project_id":29316529,"status":"success","source":"push","ref":"1-fake-issue-3","sha":"001eb421e586a3f07f90aea102c8b2d4068ab5b6","web_url":"https://gitlab.com/OWNER/REPO/-/pipelines/452944621","updated_at":"2022-01-20T21:21:04.802Z","created_at":"2022-01-20T21:20:50.971Z"},{"id":452941417,"iid":12,"project_id":29316529,"status":"success","source":"push","ref":"1-fake-issue","sha":"001eb421e586a3f07f90aea102c8b2d4068ab5b6","web_url":"https://gitlab.com/OWNER/REPO/-/pipelines/452941417","updated_at":"2022-01-20T21:15:55.2Z","created_at":"2022-01-20T21:15:42.546Z"},{"id":452939664,"iid":11,"project_id":29316529,"status":"success","source":"push","ref":"1-mr","sha":"001eb421e586a3f07f90aea102c8b2d4068ab5b6","web_url":"https://gitlab.com/OWNER/REPO/-/pipelines/452939664","updated_at":"2022-01-20T21:12:50.132Z","created_at":"2022-01-20T21:12:35.048Z"},{"id":450719821,"iid":10,"project_id":29316529,"status":"success","source":"push","ref":"OWNER-main-patch-25608","sha":"123f34ebfd5d97ef562974e55e01b83f06ae7b4a","web_url":"https://gitlab.com/OWNER/REPO/-/pipelines/450719821","updated_at":"2022-01-18T18:08:09.708Z","created_at":"2022-01-18T18:06:49.629Z"},{"id":450714758,"iid":9,"project_id":29316529,"status":"success","source":"push","ref":"OWNER-main-patch-25608","sha":"f288fd8d797a05c2946eb5d675f9d4438a150bec","web_url":"https://gitlab.com/OWNER/REPO/-/pipelines/450714758","updated_at":"2022-01-18T18:05:23.843Z","created_at":"2022-01-18T18:04:03.546Z"},{"id":450707660,"iid":8,"project_id":29316529,"status":"success","source":"push","ref":"OWNER-main-patch-25608","sha":"afe2714d50f156567ab87c2434cd901de7d341dc","web_url":"https://gitlab.com/OWNER/REPO/-/pipelines/450707660","updated_at":"2022-01-18T18:01:53.086Z","created_at":"2022-01-18T18:00:31.663Z"},{"id":450615878,"iid":7,"project_id":29316529,"status":"success","source":"push","ref":"OWNER-main-patch-25608","sha":"a4030d817a2881f5998e6466b9ba90914aecfb18","web_url":"https://gitlab.com/OWNER/REPO/-/pipelines/450615878","updated_at":"2022-01-18T17:03:22.021Z","created_at":"2022-01-18T17:02:16.204Z"},{"id":364128214,"iid":6,"project_id":29316529,"status":"success","source":"push","ref":"main","sha":"001eb421e586a3f07f90aea102c8b2d4068ab5b6","web_url":"https://gitlab.com/OWNER/REPO/-/pipelines/364128214","updated_at":"2021-09-02T14:20:07.8Z","created_at":"2021-09-02T14:19:52.731Z"},{"id":364109593,"iid":5,"project_id":29316529,"status":"success","source":"web","ref":"main","sha":"2a10724040f892e45917e4aef03cdb821e98bd99","web_url":"https://gitlab.com/OWNER/REPO/-/pipelines/364109593","updated_at":"2021-09-02T13:58:35.804Z","created_at":"2021-09-02T13:58:21.181Z"},{"id":364109341,"iid":4,"project_id":29316529,"status":"success","source":"push","ref":"main","sha":"2a10724040f892e45917e4aef03cdb821e98bd99","web_url":"https://gitlab.com/OWNER/REPO/-/pipelines/364109341","updated_at":"2021-09-02T13:58:11.734Z","created_at":"2021-09-02T13:57:59.126Z"},{"id":364104462,"iid":3,"project_id":29316529,"status":"success","source":"web","ref":"main","sha":"65fb4980734c4b84fa1f7c934c92f747a6fe3ed0","web_url":"https://gitlab.com/OWNER/REPO/-/pipelines/364104462","updated_at":"2021-09-02T13:51:57.057Z","created_at":"2021-09-02T13:51:43.615Z"},{"id":364102457,"iid":2,"project_id":29316529,"status":"success","source":"push","ref":"main","sha":"65fb4980734c4b84fa1f7c934c92f747a6fe3ed0","web_url":"https://gitlab.com/OWNER/REPO/-/pipelines/364102457","updated_at":"2021-09-02T13:49:10.689Z","created_at":"2021-09-02T13:48:58.178Z"},{"id":364098384,"iid":1,"project_id":29316529,"status":"skipped","source":"push","ref":"main","sha":"6bd3a42163672bb5341075021d74231c3d75d4b8","web_url":"https://gitlab.com/OWNER/REPO/-/pipelines/364098384","updated_at":"2021-09-02T13:43:57.758Z","created_at":"2021-09-02T13:43:57.758Z"}] diff --git a/test/json_output_data/issue_list.json b/test/json_output_data/issue_list.json new file mode 100644 index 000000000..9bd591c50 --- /dev/null +++ b/test/json_output_data/issue_list.json @@ -0,0 +1,78 @@ +[ + { + "request": { + "url": "/api/v4/projects/OWNER%2FREPO/issues?in=title%2Cdescription&page=1&per_page=30&state=opened", + "method": "GET" + }, + "response": { + "body": [ + { + "id": 101004697, + "iid": 1, + "project_id": 29316529, + "title": "fake issue", + "description": "", + "state": "opened", + "created_at": "2022-01-20T21:11:56.452Z", + "updated_at": "2022-01-20T21:20:51.007Z", + "closed_at": null, + "closed_by": null, + "labels": [], + "milestone": null, + "assignees": [], + "author": { + "id": 8814129, + "username": "OWNER", + "name": "Some User", + "state": "active", + "locked": false, + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", + "web_url": "https://gitlab.com/OWNER" + }, + "type": "ISSUE", + "assignee": null, + "user_notes_count": 0, + "merge_requests_count": 3, + "upvotes": 0, + "downvotes": 0, + "due_date": null, + "confidential": false, + "discussion_locked": null, + "issue_type": "issue", + "web_url": "https://gitlab.com/OWNER/REPO/-/issues/1", + "time_stats": { + "time_estimate": 0, + "total_time_spent": 0, + "human_time_estimate": null, + "human_total_time_spent": null + }, + "task_completion_status": { + "count": 0, + "completed_count": 0 + }, + "weight": null, + "blocking_issues_count": 0, + "has_tasks": true, + "task_status": "", + "_links": { + "self": "https://gitlab.com/api/v4/projects/29316529/issues/1", + "notes": "https://gitlab.com/api/v4/projects/29316529/issues/1/notes", + "award_emoji": "https://gitlab.com/api/v4/projects/29316529/issues/1/award_emoji", + "project": "https://gitlab.com/api/v4/projects/29316529", + "closed_as_duplicate_of": null + }, + "references": { + "short": "#1", + "relative": "#1", + "full": "OWNER/REPO#1" + }, + "severity": "UNKNOWN", + "moved_to_id": null, + "service_desk_reply_to": null, + "health_status": null + } + ], + "status": 200 + } + } +] diff --git a/test/json_output_data/issue_list_result.json b/test/json_output_data/issue_list_result.json new file mode 100644 index 000000000..f07bbb232 --- /dev/null +++ b/test/json_output_data/issue_list_result.json @@ -0,0 +1 @@ +[{"id":101004697,"iid":1,"external_id":"","state":"opened","description":"","health_status":"","author":{"id":8814129,"state":"active","web_url":"https://gitlab.com/OWNER","name":"Some User","avatar_url":"https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png","username":"OWNER"},"milestone":null,"project_id":29316529,"assignees":[],"assignee":null,"updated_at":"2022-01-20T21:20:51.007Z","closed_at":null,"closed_by":null,"title":"fake issue","created_at":"2022-01-20T21:11:56.452Z","moved_to_id":0,"labels":"","label_details":null,"upvotes":0,"downvotes":0,"due_date":null,"web_url":"https://gitlab.com/OWNER/REPO/-/issues/1","references":{"short":"#1","relative":"#1","full":"OWNER/REPO#1"},"time_stats":{"human_time_estimate":"","human_total_time_spent":"","time_estimate":0,"total_time_spent":0},"confidential":false,"weight":0,"discussion_locked":false,"issue_type":"issue","subscribed":false,"user_notes_count":0,"_links":{"self":"https://gitlab.com/api/v4/projects/29316529/issues/1","notes":"https://gitlab.com/api/v4/projects/29316529/issues/1/notes","award_emoji":"https://gitlab.com/api/v4/projects/29316529/issues/1/award_emoji","project":"https://gitlab.com/api/v4/projects/29316529"},"issue_link_id":0,"merge_requests_count":3,"epic_issue_id":0,"epic":null,"iteration":null,"task_completion_status":{"count":0,"completed_count":0}}] diff --git a/test/json_output_data/issue_view.json b/test/json_output_data/issue_view.json new file mode 100644 index 000000000..54cac4a08 --- /dev/null +++ b/test/json_output_data/issue_view.json @@ -0,0 +1,77 @@ +[ + { + "request": { + "url": "/api/v4/projects/OWNER%2FREPO/issues/1", + "method": "GET" + }, + "response": { + "body": { + "id": 101004697, + "iid": 1, + "project_id": 29316529, + "title": "fake issue", + "description": "", + "state": "opened", + "created_at": "2022-01-20T21:11:56.452Z", + "updated_at": "2022-01-20T21:20:51.007Z", + "closed_at": null, + "closed_by": null, + "labels": [], + "milestone": null, + "assignees": [], + "author": { + "id": 8814129, + "username": "OWNER", + "name": "Some User", + "state": "active", + "locked": false, + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", + "web_url": "https://gitlab.com/OWNER" + }, + "type": "ISSUE", + "assignee": null, + "user_notes_count": 0, + "merge_requests_count": 3, + "upvotes": 0, + "downvotes": 0, + "due_date": null, + "confidential": false, + "discussion_locked": null, + "issue_type": "issue", + "web_url": "https://gitlab.com/OWNER/REPO/-/issues/1", + "time_stats": { + "time_estimate": 0, + "total_time_spent": 0, + "human_time_estimate": null, + "human_total_time_spent": null + }, + "task_completion_status": { + "count": 0, + "completed_count": 0 + }, + "weight": null, + "blocking_issues_count": 0, + "has_tasks": true, + "task_status": "", + "_links": { + "self": "https://gitlab.com/api/v4/projects/29316529/issues/1", + "notes": "https://gitlab.com/api/v4/projects/29316529/issues/1/notes", + "award_emoji": "https://gitlab.com/api/v4/projects/29316529/issues/1/award_emoji", + "project": "https://gitlab.com/api/v4/projects/29316529", + "closed_as_duplicate_of": null + }, + "references": { + "short": "#1", + "relative": "#1", + "full": "OWNER/REPO#1" + }, + "severity": "UNKNOWN", + "subscribed": true, + "moved_to_id": null, + "service_desk_reply_to": null, + "health_status": null + }, + "status": 200 + } + } +] diff --git a/test/json_output_data/issue_view_result.json b/test/json_output_data/issue_view_result.json new file mode 100644 index 000000000..f25ff2a6a --- /dev/null +++ b/test/json_output_data/issue_view_result.json @@ -0,0 +1 @@ +{"id":101004697,"iid":1,"external_id":"","state":"opened","description":"","health_status":"","author":{"id":8814129,"state":"active","web_url":"https://gitlab.com/OWNER","name":"Some User","avatar_url":"https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png","username":"OWNER"},"milestone":null,"project_id":29316529,"assignees":[],"assignee":null,"updated_at":"2022-01-20T21:20:51.007Z","closed_at":null,"closed_by":null,"title":"fake issue","created_at":"2022-01-20T21:11:56.452Z","moved_to_id":0,"labels":"","label_details":null,"upvotes":0,"downvotes":0,"due_date":null,"web_url":"https://gitlab.com/OWNER/REPO/-/issues/1","references":{"short":"#1","relative":"#1","full":"OWNER/REPO#1"},"time_stats":{"human_time_estimate":"","human_total_time_spent":"","time_estimate":0,"total_time_spent":0},"confidential":false,"weight":0,"discussion_locked":false,"issue_type":"issue","subscribed":true,"user_notes_count":0,"_links":{"self":"https://gitlab.com/api/v4/projects/29316529/issues/1","notes":"https://gitlab.com/api/v4/projects/29316529/issues/1/notes","award_emoji":"https://gitlab.com/api/v4/projects/29316529/issues/1/award_emoji","project":"https://gitlab.com/api/v4/projects/29316529"},"issue_link_id":0,"merge_requests_count":3,"epic_issue_id":0,"epic":null,"iteration":null,"task_completion_status":{"count":0,"completed_count":0}} diff --git a/test/json_output_data/label_list.json b/test/json_output_data/label_list.json new file mode 100644 index 000000000..7117daf94 --- /dev/null +++ b/test/json_output_data/label_list.json @@ -0,0 +1,27 @@ +[ + { + "request": { + "url": "/api/v4/projects/OWNER%2FREPO/labels?page=1&per_page=30&with_counts=true", + "method": "GET" + }, + "response": { + "body": [ + { + "id": 29739671, + "name": "my label", + "description": "Simple label", + "description_html": "Simple label", + "text_color": "#FFFFFF", + "color": "#00b140", + "open_issues_count": 0, + "closed_issues_count": 0, + "open_merge_requests_count": 0, + "subscribed": false, + "priority": null, + "is_project_label": true + } + ], + "status": 200 + } + } +] diff --git a/test/json_output_data/label_list_result.json b/test/json_output_data/label_list_result.json new file mode 100644 index 000000000..2cca36850 --- /dev/null +++ b/test/json_output_data/label_list_result.json @@ -0,0 +1 @@ +[{"id":29739671,"name":"my label","color":"#00b140","text_color":"#FFFFFF","description":"Simple label","open_issues_count":0,"closed_issues_count":0,"open_merge_requests_count":0,"subscribed":false,"priority":0,"is_project_label":true}] diff --git a/test/json_output_data/mr_list.json b/test/json_output_data/mr_list.json new file mode 100644 index 000000000..15385fa24 --- /dev/null +++ b/test/json_output_data/mr_list.json @@ -0,0 +1,171 @@ +[ + { + "request": { + "url": "/api/v4/projects/OWNER%2FREPO/merge_requests?page=1&per_page=30&state=opened", + "method": "GET" + }, + "response": { + "body": [ + { + "id": 136297744, + "iid": 4, + "project_id": 29316529, + "title": "Draft: Resolve \"fake issue\"", + "description": "Closes #1", + "state": "opened", + "created_at": "2022-01-20T21:20:50.665Z", + "updated_at": "2022-01-20T21:47:54.110Z", + "merged_by": null, + "merge_user": null, + "merged_at": null, + "closed_by": null, + "closed_at": null, + "target_branch": "main", + "source_branch": "1-fake-issue-3", + "user_notes_count": 0, + "upvotes": 0, + "downvotes": 0, + "author": { + "id": 8814129, + "username": "OWNER", + "name": "Some User", + "state": "active", + "locked": false, + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", + "web_url": "https://gitlab.com/OWNER" + }, + "assignees": [ + { + "id": 8814129, + "username": "OWNER", + "name": "Some User", + "state": "active", + "locked": false, + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", + "web_url": "https://gitlab.com/OWNER" + } + ], + "assignee": { + "id": 8814129, + "username": "OWNER", + "name": "Some User", + "state": "active", + "locked": false, + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", + "web_url": "https://gitlab.com/OWNER" + }, + "reviewers": [], + "source_project_id": 29316529, + "target_project_id": 29316529, + "labels": [], + "draft": true, + "work_in_progress": true, + "milestone": null, + "merge_when_pipeline_succeeds": false, + "merge_status": "can_be_merged", + "detailed_merge_status": "draft_status", + "sha": "44eb489568f7cb1a5a730fce6b247cd3797172ca", + "merge_commit_sha": null, + "squash_commit_sha": null, + "discussion_locked": null, + "should_remove_source_branch": null, + "force_remove_source_branch": true, + "prepared_at": "2022-01-20T21:20:50.665Z", + "reference": "!4", + "references": { + "short": "!4", + "relative": "!4", + "full": "OWNER/REPO!4" + }, + "web_url": "https://gitlab.com/OWNER/REPO/-/merge_requests/4", + "time_stats": { + "time_estimate": 0, + "total_time_spent": 0, + "human_time_estimate": null, + "human_total_time_spent": null + }, + "squash": false, + "squash_on_merge": false, + "task_completion_status": { + "count": 0, + "completed_count": 0 + }, + "has_conflicts": false, + "blocking_discussions_resolved": true, + "approvals_before_merge": null + }, + { + "id": 135750125, + "iid": 1, + "project_id": 29316529, + "title": "Update .gitlab-ci.yml", + "description": "", + "state": "opened", + "created_at": "2022-01-18T17:02:23.270Z", + "updated_at": "2022-01-18T18:06:50.054Z", + "merged_by": null, + "merge_user": null, + "merged_at": null, + "closed_by": null, + "closed_at": null, + "target_branch": "main", + "source_branch": "OWNER-main-patch-25608", + "user_notes_count": 0, + "upvotes": 0, + "downvotes": 0, + "author": { + "id": 8814129, + "username": "OWNER", + "name": "Some User", + "state": "active", + "locked": false, + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", + "web_url": "https://gitlab.com/OWNER" + }, + "assignees": [], + "assignee": null, + "reviewers": [], + "source_project_id": 29316529, + "target_project_id": 29316529, + "labels": [], + "draft": false, + "work_in_progress": false, + "milestone": null, + "merge_when_pipeline_succeeds": false, + "merge_status": "can_be_merged", + "detailed_merge_status": "mergeable", + "sha": "123f34ebfd5d97ef562974e55e01b83f06ae7b4a", + "merge_commit_sha": null, + "squash_commit_sha": null, + "discussion_locked": null, + "should_remove_source_branch": null, + "force_remove_source_branch": true, + "prepared_at": "2022-01-18T17:02:23.270Z", + "reference": "!1", + "references": { + "short": "!1", + "relative": "!1", + "full": "OWNER/REPO!1" + }, + "web_url": "https://gitlab.com/OWNER/REPO/-/merge_requests/1", + "time_stats": { + "time_estimate": 0, + "total_time_spent": 0, + "human_time_estimate": null, + "human_total_time_spent": null + }, + "squash": false, + "squash_on_merge": false, + "task_completion_status": { + "count": 0, + "completed_count": 0 + }, + "has_conflicts": false, + "blocking_discussions_resolved": true, + "approvals_before_merge": null + } + ], + "status": 200 + } + } +] diff --git a/test/json_output_data/mr_list_result.json b/test/json_output_data/mr_list_result.json new file mode 100644 index 000000000..d803df641 --- /dev/null +++ b/test/json_output_data/mr_list_result.json @@ -0,0 +1 @@ +[{"id":136297744,"iid":4,"target_branch":"main","source_branch":"1-fake-issue-3","project_id":29316529,"title":"Draft: Resolve \"fake issue\"","state":"opened","created_at":"2022-01-20T21:20:50.665Z","updated_at":"2022-01-20T21:47:54.11Z","upvotes":0,"downvotes":0,"author":{"id":8814129,"username":"OWNER","name":"Some User","state":"active","created_at":null,"avatar_url":"https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png","web_url":"https://gitlab.com/OWNER"},"assignee":{"id":8814129,"username":"OWNER","name":"Some User","state":"active","created_at":null,"avatar_url":"https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png","web_url":"https://gitlab.com/OWNER"},"assignees":[{"id":8814129,"username":"OWNER","name":"Some User","state":"active","created_at":null,"avatar_url":"https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png","web_url":"https://gitlab.com/OWNER"}],"reviewers":[],"source_project_id":29316529,"target_project_id":29316529,"labels":"","label_details":null,"description":"Closes #1","draft":true,"work_in_progress":true,"milestone":null,"merge_when_pipeline_succeeds":false,"detailed_merge_status":"draft_status","merge_error":"","merged_by":null,"merged_at":null,"closed_by":null,"closed_at":null,"subscribed":false,"sha":"44eb489568f7cb1a5a730fce6b247cd3797172ca","merge_commit_sha":"","squash_commit_sha":"","user_notes_count":0,"changes_count":"","should_remove_source_branch":false,"force_remove_source_branch":true,"allow_collaboration":false,"web_url":"https://gitlab.com/OWNER/REPO/-/merge_requests/4","references":{"short":"!4","relative":"!4","full":"OWNER/REPO!4"},"discussion_locked":false,"changes":null,"user":{"can_merge":false},"time_stats":{"human_time_estimate":"","human_total_time_spent":"","time_estimate":0,"total_time_spent":0},"squash":false,"pipeline":null,"head_pipeline":null,"diff_refs":{"base_sha":"","head_sha":"","start_sha":""},"diverged_commits_count":0,"rebase_in_progress":false,"approvals_before_merge":0,"reference":"!4","first_contribution":false,"task_completion_status":{"count":0,"completed_count":0},"has_conflicts":false,"blocking_discussions_resolved":true,"overflow":false,"merge_status":"can_be_merged"},{"id":135750125,"iid":1,"target_branch":"main","source_branch":"OWNER-main-patch-25608","project_id":29316529,"title":"Update .gitlab-ci.yml","state":"opened","created_at":"2022-01-18T17:02:23.27Z","updated_at":"2022-01-18T18:06:50.054Z","upvotes":0,"downvotes":0,"author":{"id":8814129,"username":"OWNER","name":"Some User","state":"active","created_at":null,"avatar_url":"https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png","web_url":"https://gitlab.com/OWNER"},"assignee":null,"assignees":[],"reviewers":[],"source_project_id":29316529,"target_project_id":29316529,"labels":"","label_details":null,"description":"","draft":false,"work_in_progress":false,"milestone":null,"merge_when_pipeline_succeeds":false,"detailed_merge_status":"mergeable","merge_error":"","merged_by":null,"merged_at":null,"closed_by":null,"closed_at":null,"subscribed":false,"sha":"123f34ebfd5d97ef562974e55e01b83f06ae7b4a","merge_commit_sha":"","squash_commit_sha":"","user_notes_count":0,"changes_count":"","should_remove_source_branch":false,"force_remove_source_branch":true,"allow_collaboration":false,"web_url":"https://gitlab.com/OWNER/REPO/-/merge_requests/1","references":{"short":"!1","relative":"!1","full":"OWNER/REPO!1"},"discussion_locked":false,"changes":null,"user":{"can_merge":false},"time_stats":{"human_time_estimate":"","human_total_time_spent":"","time_estimate":0,"total_time_spent":0},"squash":false,"pipeline":null,"head_pipeline":null,"diff_refs":{"base_sha":"","head_sha":"","start_sha":""},"diverged_commits_count":0,"rebase_in_progress":false,"approvals_before_merge":0,"reference":"!1","first_contribution":false,"task_completion_status":{"count":0,"completed_count":0},"has_conflicts":false,"blocking_discussions_resolved":true,"overflow":false,"merge_status":"can_be_merged"}] diff --git a/test/json_output_data/mr_view.json b/test/json_output_data/mr_view.json new file mode 100644 index 000000000..6fef9b18b --- /dev/null +++ b/test/json_output_data/mr_view.json @@ -0,0 +1,184 @@ +[ + { + "request": { + "url": "/api/v4/projects/OWNER%2FREPO/merge_requests/4?include_diverged_commits_count=true&include_rebase_in_progress=true&render_html=true", + "method": "GET" + }, + "response": { + "body": { + "id": 136297744, + "iid": 4, + "project_id": 29316529, + "title": "Draft: Resolve \"fake issue\"", + "description": "Closes #1", + "state": "opened", + "created_at": "2022-01-20T21:20:50.665Z", + "updated_at": "2022-01-20T21:47:54.110Z", + "merged_by": null, + "merge_user": null, + "merged_at": null, + "closed_by": null, + "closed_at": null, + "title_html": "Draft: Resolve \"fake issue\"", + "description_html": "

Closes #1

", + "target_branch": "main", + "source_branch": "1-fake-issue-3", + "user_notes_count": 0, + "upvotes": 0, + "downvotes": 0, + "author": { + "id": 8814129, + "username": "OWNER", + "name": "Some User", + "state": "active", + "locked": false, + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", + "web_url": "https://gitlab.com/OWNER" + }, + "assignees": [ + { + "id": 8814129, + "username": "OWNER", + "name": "Some User", + "state": "active", + "locked": false, + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", + "web_url": "https://gitlab.com/OWNER" + } + ], + "assignee": { + "id": 8814129, + "username": "OWNER", + "name": "Some User", + "state": "active", + "locked": false, + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", + "web_url": "https://gitlab.com/OWNER" + }, + "reviewers": [], + "source_project_id": 29316529, + "target_project_id": 29316529, + "labels": [], + "draft": true, + "work_in_progress": true, + "milestone": null, + "merge_when_pipeline_succeeds": false, + "merge_status": "can_be_merged", + "detailed_merge_status": "draft_status", + "sha": "44eb489568f7cb1a5a730fce6b247cd3797172ca", + "merge_commit_sha": null, + "squash_commit_sha": null, + "discussion_locked": null, + "should_remove_source_branch": null, + "force_remove_source_branch": true, + "prepared_at": "2022-01-20T21:20:50.665Z", + "reference": "!4", + "references": { + "short": "!4", + "relative": "!4", + "full": "OWNER/REPO!4" + }, + "web_url": "https://gitlab.com/OWNER/REPO/-/merge_requests/4", + "time_stats": { + "time_estimate": 0, + "total_time_spent": 0, + "human_time_estimate": null, + "human_total_time_spent": null + }, + "squash": false, + "squash_on_merge": false, + "task_completion_status": { + "count": 0, + "completed_count": 0 + }, + "has_conflicts": false, + "blocking_discussions_resolved": true, + "approvals_before_merge": null, + "subscribed": true, + "changes_count": "1", + "latest_build_started_at": "2022-01-20T21:47:17.448Z", + "latest_build_finished_at": "2022-01-20T21:47:31.350Z", + "first_deployed_to_production_at": null, + "pipeline": { + "id": 452959326, + "iid": 14, + "project_id": 29316529, + "sha": "44eb489568f7cb1a5a730fce6b247cd3797172ca", + "ref": "1-fake-issue-3", + "status": "success", + "source": "push", + "created_at": "2022-01-20T21:47:16.276Z", + "updated_at": "2022-01-20T21:47:31.358Z", + "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/452959326" + }, + "head_pipeline": { + "id": 452959326, + "iid": 14, + "project_id": 29316529, + "sha": "44eb489568f7cb1a5a730fce6b247cd3797172ca", + "ref": "1-fake-issue-3", + "status": "success", + "source": "push", + "created_at": "2022-01-20T21:47:16.276Z", + "updated_at": "2022-01-20T21:47:31.358Z", + "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/452959326", + "before_sha": "001eb421e586a3f07f90aea102c8b2d4068ab5b6", + "tag": false, + "yaml_errors": null, + "user": { + "id": 8814129, + "username": "OWNER", + "name": "Some User", + "state": "active", + "locked": false, + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", + "web_url": "https://gitlab.com/OWNER" + }, + "started_at": "2022-01-20T21:47:17.448Z", + "finished_at": "2022-01-20T21:47:31.350Z", + "committed_at": null, + "duration": 14, + "queued_duration": 1, + "coverage": null, + "detailed_status": { + "icon": "status_success", + "text": "Passed", + "label": "passed", + "group": "success", + "tooltip": "passed", + "has_details": true, + "details_path": "/OWNER/REPO/-/pipelines/452959326", + "illustration": null, + "favicon": "/assets/ci_favicons/favicon_status_success-8451333011eee8ce9f2ab25dc487fe24a8758c694827a582f17f42b0a90446a2.png" + } + }, + "diff_refs": { + "base_sha": "001eb421e586a3f07f90aea102c8b2d4068ab5b6", + "head_sha": "44eb489568f7cb1a5a730fce6b247cd3797172ca", + "start_sha": "001eb421e586a3f07f90aea102c8b2d4068ab5b6" + }, + "merge_error": null, + "rebase_in_progress": false, + "diverged_commits_count": 0, + "first_contribution": true, + "user": { + "can_merge": true + } + }, + "status": 200 + } + }, + { + "request": { + "url": "/api/v4/projects/OWNER%2FREPO/merge_requests/4/approval_state", + "method": "GET" + }, + "response": { + "body": { + "approval_rules_overwritten": false, + "rules": [] + }, + "status": 200 + } + } +] diff --git a/test/json_output_data/mr_view_result.json b/test/json_output_data/mr_view_result.json new file mode 100644 index 000000000..c0c905996 --- /dev/null +++ b/test/json_output_data/mr_view_result.json @@ -0,0 +1 @@ +{"id":136297744,"iid":4,"target_branch":"main","source_branch":"1-fake-issue-3","project_id":29316529,"title":"Draft: Resolve \"fake issue\"","state":"opened","created_at":"2022-01-20T21:20:50.665Z","updated_at":"2022-01-20T21:47:54.11Z","upvotes":0,"downvotes":0,"author":{"id":8814129,"username":"OWNER","name":"Some User","state":"active","created_at":null,"avatar_url":"https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png","web_url":"https://gitlab.com/OWNER"},"assignee":{"id":8814129,"username":"OWNER","name":"Some User","state":"active","created_at":null,"avatar_url":"https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png","web_url":"https://gitlab.com/OWNER"},"assignees":[{"id":8814129,"username":"OWNER","name":"Some User","state":"active","created_at":null,"avatar_url":"https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png","web_url":"https://gitlab.com/OWNER"}],"reviewers":[],"source_project_id":29316529,"target_project_id":29316529,"labels":"","label_details":null,"description":"Closes #1","draft":true,"work_in_progress":true,"milestone":null,"merge_when_pipeline_succeeds":false,"detailed_merge_status":"draft_status","merge_error":"","merged_by":null,"merged_at":null,"closed_by":null,"closed_at":null,"subscribed":true,"sha":"44eb489568f7cb1a5a730fce6b247cd3797172ca","merge_commit_sha":"","squash_commit_sha":"","user_notes_count":0,"changes_count":"1","should_remove_source_branch":false,"force_remove_source_branch":true,"allow_collaboration":false,"web_url":"https://gitlab.com/OWNER/REPO/-/merge_requests/4","references":{"short":"!4","relative":"!4","full":"OWNER/REPO!4"},"discussion_locked":false,"changes":null,"user":{"can_merge":true},"time_stats":{"human_time_estimate":"","human_total_time_spent":"","time_estimate":0,"total_time_spent":0},"squash":false,"pipeline":{"id":452959326,"iid":14,"project_id":29316529,"status":"success","source":"push","ref":"1-fake-issue-3","sha":"44eb489568f7cb1a5a730fce6b247cd3797172ca","web_url":"https://gitlab.com/OWNER/REPO/-/pipelines/452959326","updated_at":"2022-01-20T21:47:31.358Z","created_at":"2022-01-20T21:47:16.276Z"},"head_pipeline":{"id":452959326,"iid":14,"project_id":29316529,"status":"success","source":"push","ref":"1-fake-issue-3","sha":"44eb489568f7cb1a5a730fce6b247cd3797172ca","before_sha":"001eb421e586a3f07f90aea102c8b2d4068ab5b6","tag":false,"yaml_errors":"","user":{"id":8814129,"username":"OWNER","name":"Some User","state":"active","created_at":null,"avatar_url":"https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png","web_url":"https://gitlab.com/OWNER"},"updated_at":"2022-01-20T21:47:31.358Z","created_at":"2022-01-20T21:47:16.276Z","started_at":"2022-01-20T21:47:17.448Z","finished_at":"2022-01-20T21:47:31.35Z","committed_at":null,"duration":14,"queued_duration":1,"coverage":"","web_url":"https://gitlab.com/OWNER/REPO/-/pipelines/452959326","detailed_status":{"icon":"status_success","text":"Passed","label":"passed","group":"success","tooltip":"passed","has_details":true,"details_path":"/OWNER/REPO/-/pipelines/452959326","illustration":{"image":""},"favicon":"/assets/ci_favicons/favicon_status_success-8451333011eee8ce9f2ab25dc487fe24a8758c694827a582f17f42b0a90446a2.png"}},"diff_refs":{"base_sha":"001eb421e586a3f07f90aea102c8b2d4068ab5b6","head_sha":"44eb489568f7cb1a5a730fce6b247cd3797172ca","start_sha":"001eb421e586a3f07f90aea102c8b2d4068ab5b6"},"diverged_commits_count":0,"rebase_in_progress":false,"approvals_before_merge":0,"reference":"!4","first_contribution":true,"task_completion_status":{"count":0,"completed_count":0},"has_conflicts":false,"blocking_discussions_resolved":true,"overflow":false,"merge_status":"can_be_merged"} diff --git a/test/json_output_data/project_list.json b/test/json_output_data/project_list.json new file mode 100644 index 000000000..4774dc593 --- /dev/null +++ b/test/json_output_data/project_list.json @@ -0,0 +1,175 @@ +[ + { + "request": { + "url": "/api/v4/projects?order_by=last_activity_at&owned=true&page=1&per_page=1", + "method": "GET" + }, + "response": { + "body": [ + { + "id": 54865235, + "description": null, + "name": "glab-json", + "name_with_namespace": "Some User / glab-json", + "path": "glab-json", + "path_with_namespace": "OWNER/glab-json", + "created_at": "2024-02-12T19:20:00.943Z", + "default_branch": "main", + "tag_list": [], + "topics": [], + "ssh_url_to_repo": "git@gitlab.com:OWNER/glab-json.git", + "http_url_to_repo": "https://gitlab.com/OWNER/glab-json.git", + "web_url": "https://gitlab.com/OWNER/glab-json", + "readme_url": null, + "forks_count": 0, + "avatar_url": null, + "star_count": 0, + "last_activity_at": "2024-02-12T19:20:00.874Z", + "namespace": { + "id": 11940376, + "name": "Some User", + "path": "OWNER", + "kind": "user", + "full_path": "OWNER", + "parent_id": null, + "avatar_url": "/uploads/-/system/user/avatar/8814129/avatar.png", + "web_url": "https://gitlab.com/OWNER" + }, + "container_registry_image_prefix": "registry.gitlab.com/OWNER/glab-json", + "_links": { + "self": "https://gitlab.com/api/v4/projects/54865235", + "issues": "https://gitlab.com/api/v4/projects/54865235/issues", + "merge_requests": "https://gitlab.com/api/v4/projects/54865235/merge_requests", + "repo_branches": "https://gitlab.com/api/v4/projects/54865235/repository/branches", + "labels": "https://gitlab.com/api/v4/projects/54865235/labels", + "events": "https://gitlab.com/api/v4/projects/54865235/events", + "members": "https://gitlab.com/api/v4/projects/54865235/members", + "cluster_agents": "https://gitlab.com/api/v4/projects/54865235/cluster_agents" + }, + "packages_enabled": true, + "empty_repo": true, + "archived": false, + "visibility": "public", + "owner": { + "id": 8814129, + "username": "OWNER", + "name": "Some User", + "state": "active", + "locked": false, + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", + "web_url": "https://gitlab.com/OWNER" + }, + "resolve_outdated_diff_discussions": false, + "container_expiration_policy": { + "cadence": "1d", + "enabled": false, + "keep_n": 10, + "older_than": "90d", + "name_regex": ".*", + "name_regex_keep": null, + "next_run_at": "2024-02-13T19:20:00.985Z" + }, + "repository_object_format": "sha1", + "issues_enabled": true, + "merge_requests_enabled": true, + "wiki_enabled": true, + "jobs_enabled": true, + "snippets_enabled": true, + "container_registry_enabled": true, + "service_desk_enabled": true, + "service_desk_address": "contact-project+OWNER-glab-json-54865235-issue-@incoming.gitlab.com", + "can_create_merge_request_in": true, + "issues_access_level": "enabled", + "repository_access_level": "enabled", + "merge_requests_access_level": "enabled", + "forking_access_level": "enabled", + "wiki_access_level": "enabled", + "builds_access_level": "enabled", + "snippets_access_level": "enabled", + "pages_access_level": "enabled", + "analytics_access_level": "enabled", + "container_registry_access_level": "enabled", + "security_and_compliance_access_level": "private", + "releases_access_level": "enabled", + "environments_access_level": "enabled", + "feature_flags_access_level": "enabled", + "infrastructure_access_level": "enabled", + "monitor_access_level": "enabled", + "model_experiments_access_level": "enabled", + "model_registry_access_level": "enabled", + "emails_disabled": false, + "emails_enabled": true, + "shared_runners_enabled": true, + "lfs_enabled": true, + "creator_id": 8814129, + "import_url": null, + "import_type": null, + "import_status": "none", + "open_issues_count": 0, + "description_html": "", + "updated_at": "2024-02-12T19:20:00.943Z", + "ci_default_git_depth": 20, + "ci_forward_deployment_enabled": true, + "ci_forward_deployment_rollback_allowed": true, + "ci_job_token_scope_enabled": false, + "ci_separated_caches": true, + "ci_allow_fork_pipelines_to_run_in_parent_project": true, + "build_git_strategy": "fetch", + "keep_latest_artifact": true, + "restrict_user_defined_variables": false, + "runners_token": "GR1348941D1R_d-qgi-xpbQrpttEg", + "runner_token_expiration_interval": null, + "group_runners_enabled": true, + "auto_cancel_pending_pipelines": "enabled", + "build_timeout": 3600, + "auto_devops_enabled": false, + "auto_devops_deploy_strategy": "continuous", + "ci_config_path": "", + "public_jobs": true, + "shared_with_groups": [], + "only_allow_merge_if_pipeline_succeeds": false, + "allow_merge_on_skipped_pipeline": null, + "request_access_enabled": true, + "only_allow_merge_if_all_discussions_are_resolved": false, + "remove_source_branch_after_merge": true, + "printing_merge_request_link_enabled": true, + "merge_method": "merge", + "squash_option": "default_off", + "enforce_auth_checks_on_uploads": true, + "suggestion_commit_message": null, + "merge_commit_template": null, + "squash_commit_template": null, + "issue_branch_template": null, + "warn_about_potentially_unwanted_characters": true, + "autoclose_referenced_issues": true, + "approvals_before_merge": 0, + "mirror": false, + "external_authorization_classification_label": "", + "marked_for_deletion_at": null, + "marked_for_deletion_on": null, + "requirements_enabled": true, + "requirements_access_level": "enabled", + "security_and_compliance_enabled": true, + "compliance_frameworks": [], + "issues_template": null, + "merge_requests_template": null, + "ci_restrict_pipeline_cancellation_role": "developer", + "merge_pipelines_enabled": false, + "merge_trains_enabled": false, + "merge_trains_skip_train_allowed": false, + "only_allow_merge_if_all_status_checks_passed": false, + "allow_pipeline_trigger_approve_deployment": false, + "prevent_merge_without_jira_issue": false, + "permissions": { + "project_access": { + "access_level": 50, + "notification_level": 3 + }, + "group_access": null + } + } + ], + "status": 200 + } + } +] diff --git a/test/json_output_data/project_list_result.json b/test/json_output_data/project_list_result.json new file mode 100644 index 000000000..fd7c2838f --- /dev/null +++ b/test/json_output_data/project_list_result.json @@ -0,0 +1 @@ +[{"id":54865235,"description":"","default_branch":"main","public":false,"visibility":"public","ssh_url_to_repo":"git@gitlab.com:OWNER/glab-json.git","http_url_to_repo":"https://gitlab.com/OWNER/glab-json.git","web_url":"https://gitlab.com/OWNER/glab-json","readme_url":"","tag_list":[],"topics":[],"owner":{"id":8814129,"username":"OWNER","email":"","name":"Some User","state":"active","web_url":"https://gitlab.com/OWNER","created_at":null,"bio":"","bot":false,"location":"","public_email":"","skype":"","linkedin":"","twitter":"","website_url":"","organization":"","job_title":"","extern_uid":"","provider":"","theme_id":0,"last_activity_on":null,"color_scheme_id":0,"is_admin":false,"avatar_url":"https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png","can_create_group":false,"can_create_project":false,"projects_limit":0,"current_sign_in_at":null,"current_sign_in_ip":null,"last_sign_in_at":null,"last_sign_in_ip":null,"confirmed_at":null,"two_factor_enabled":false,"note":"","identities":null,"external":false,"private_profile":false,"shared_runners_minutes_limit":0,"extra_shared_runners_minutes_limit":0,"using_license_seat":false,"custom_attributes":null,"namespace_id":0},"name":"glab-json","name_with_namespace":"Some User / glab-json","path":"glab-json","path_with_namespace":"OWNER/glab-json","issues_enabled":true,"open_issues_count":0,"merge_requests_enabled":true,"approvals_before_merge":0,"jobs_enabled":true,"wiki_enabled":true,"snippets_enabled":true,"resolve_outdated_diff_discussions":false,"container_expiration_policy":{"cadence":"1d","keep_n":10,"older_than":"90d","name_regex":".*","name_regex_delete":"","name_regex_keep":"","enabled":false,"next_run_at":"2024-02-13T19:20:00.985Z"},"container_registry_enabled":true,"container_registry_access_level":"enabled","container_registry_image_prefix":"registry.gitlab.com/OWNER/glab-json","created_at":"2024-02-12T19:20:00.943Z","last_activity_at":"2024-02-12T19:20:00.874Z","creator_id":8814129,"namespace":{"id":11940376,"name":"Some User","path":"OWNER","kind":"user","full_path":"OWNER","parent_id":0,"avatar_url":"/uploads/-/system/user/avatar/8814129/avatar.png","web_url":"https://gitlab.com/OWNER"},"permissions":{"project_access":{"access_level":50,"notification_level":"global"},"group_access":null},"marked_for_deletion_at":null,"empty_repo":true,"archived":false,"avatar_url":"","license_url":"","license":null,"shared_runners_enabled":true,"group_runners_enabled":true,"runner_token_expiration_interval":0,"forks_count":0,"star_count":0,"runners_token":"GR1348941D1R_d-qgi-xpbQrpttEg","allow_merge_on_skipped_pipeline":false,"only_allow_merge_if_pipeline_succeeds":false,"only_allow_merge_if_all_discussions_are_resolved":false,"remove_source_branch_after_merge":true,"printing_merge_request_link_enabled":true,"lfs_enabled":true,"repository_storage":"","request_access_enabled":true,"merge_method":"merge","can_create_merge_request_in":true,"forked_from_project":null,"mirror":false,"mirror_user_id":0,"mirror_trigger_builds":false,"only_mirror_protected_branches":false,"mirror_overwrites_diverged_branches":false,"packages_enabled":true,"service_desk_enabled":true,"service_desk_address":"contact-project+OWNER-glab-json-54865235-issue-@incoming.gitlab.com","issues_access_level":"enabled","releases_access_level":"enabled","repository_access_level":"enabled","merge_requests_access_level":"enabled","forking_access_level":"enabled","wiki_access_level":"enabled","builds_access_level":"enabled","snippets_access_level":"enabled","pages_access_level":"enabled","operations_access_level":"","analytics_access_level":"enabled","environments_access_level":"enabled","feature_flags_access_level":"enabled","infrastructure_access_level":"enabled","monitor_access_level":"enabled","autoclose_referenced_issues":true,"suggestion_commit_message":"","squash_option":"default_off","enforce_auth_checks_on_uploads":true,"shared_with_groups":[],"statistics":null,"_links":{"self":"https://gitlab.com/api/v4/projects/54865235","issues":"https://gitlab.com/api/v4/projects/54865235/issues","merge_requests":"https://gitlab.com/api/v4/projects/54865235/merge_requests","repo_branches":"https://gitlab.com/api/v4/projects/54865235/repository/branches","labels":"https://gitlab.com/api/v4/projects/54865235/labels","events":"https://gitlab.com/api/v4/projects/54865235/events","members":"https://gitlab.com/api/v4/projects/54865235/members","cluster_agents":"https://gitlab.com/api/v4/projects/54865235/cluster_agents"},"import_url":"","import_type":"","import_status":"none","import_error":"","ci_default_git_depth":20,"ci_forward_deployment_enabled":true,"ci_separated_caches":true,"ci_job_token_scope_enabled":false,"ci_opt_in_jwt":false,"ci_allow_fork_pipelines_to_run_in_parent_project":true,"public_jobs":true,"build_timeout":3600,"auto_cancel_pending_pipelines":"enabled","ci_config_path":"","custom_attributes":null,"compliance_frameworks":[],"build_coverage_regex":"","issues_template":"","merge_requests_template":"","issue_branch_template":"","keep_latest_artifact":true,"merge_pipelines_enabled":false,"merge_trains_enabled":false,"restrict_user_defined_variables":false,"merge_commit_template":"","squash_commit_template":"","auto_devops_deploy_strategy":"continuous","auto_devops_enabled":false,"build_git_strategy":"fetch","emails_enabled":true,"external_authorization_classification_label":"","requirements_enabled":true,"requirements_access_level":"enabled","security_and_compliance_enabled":true,"security_and_compliance_access_level":"private","mr_default_target_self":false,"emails_disabled":false,"public_builds":false}] diff --git a/test/json_output_data/project_view.json b/test/json_output_data/project_view.json new file mode 100644 index 000000000..482d8fffe --- /dev/null +++ b/test/json_output_data/project_view.json @@ -0,0 +1,188 @@ +[ + { + "request": { + "url": "/api/v4/projects/OWNER%2FREPO?license=true&statistics=true&with_custom_attributes=true", + "method": "GET" + }, + "response": { + "body": { + "id": 29316529, + "description": "", + "name": "REPO", + "name_with_namespace": "Some User / REPO", + "path": "REPO", + "path_with_namespace": "OWNER/REPO", + "created_at": "2021-09-02T13:38:42.806Z", + "default_branch": "main", + "tag_list": [], + "topics": [], + "ssh_url_to_repo": "git@gitlab.com:OWNER/REPO.git", + "http_url_to_repo": "https://gitlab.com/OWNER/REPO.git", + "web_url": "https://gitlab.com/OWNER/REPO", + "readme_url": "https://gitlab.com/OWNER/REPO/-/blob/main/README.md", + "forks_count": 0, + "license_url": null, + "license": null, + "avatar_url": null, + "star_count": 0, + "last_activity_at": "2022-01-20T21:11:56.564Z", + "namespace": { + "id": 11940376, + "name": "Some User", + "path": "OWNER", + "kind": "user", + "full_path": "OWNER", + "parent_id": null, + "avatar_url": "/uploads/-/system/user/avatar/8814129/avatar.png", + "web_url": "https://gitlab.com/OWNER" + }, + "container_registry_image_prefix": "registry.gitlab.com/OWNER/REPO", + "_links": { + "self": "https://gitlab.com/api/v4/projects/29316529", + "issues": "https://gitlab.com/api/v4/projects/29316529/issues", + "merge_requests": "https://gitlab.com/api/v4/projects/29316529/merge_requests", + "repo_branches": "https://gitlab.com/api/v4/projects/29316529/repository/branches", + "labels": "https://gitlab.com/api/v4/projects/29316529/labels", + "events": "https://gitlab.com/api/v4/projects/29316529/events", + "members": "https://gitlab.com/api/v4/projects/29316529/members", + "cluster_agents": "https://gitlab.com/api/v4/projects/29316529/cluster_agents" + }, + "packages_enabled": true, + "empty_repo": false, + "archived": false, + "visibility": "public", + "owner": { + "id": 8814129, + "username": "OWNER", + "name": "Some User", + "state": "active", + "locked": false, + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", + "web_url": "https://gitlab.com/OWNER" + }, + "resolve_outdated_diff_discussions": false, + "container_expiration_policy": { + "cadence": "1d", + "enabled": false, + "keep_n": 10, + "older_than": "90d", + "name_regex": ".*", + "name_regex_keep": null, + "next_run_at": "2021-09-03T13:38:42.834Z" + }, + "repository_object_format": "sha1", + "issues_enabled": true, + "merge_requests_enabled": true, + "wiki_enabled": true, + "jobs_enabled": true, + "snippets_enabled": true, + "container_registry_enabled": true, + "service_desk_enabled": true, + "service_desk_address": "contact-project+OWNER-REPO-29316529-issue-@incoming.gitlab.com", + "can_create_merge_request_in": true, + "issues_access_level": "enabled", + "repository_access_level": "enabled", + "merge_requests_access_level": "enabled", + "forking_access_level": "enabled", + "wiki_access_level": "enabled", + "builds_access_level": "enabled", + "snippets_access_level": "enabled", + "pages_access_level": "enabled", + "analytics_access_level": "enabled", + "container_registry_access_level": "enabled", + "security_and_compliance_access_level": "private", + "releases_access_level": "enabled", + "environments_access_level": "enabled", + "feature_flags_access_level": "enabled", + "infrastructure_access_level": "enabled", + "monitor_access_level": "enabled", + "model_experiments_access_level": "enabled", + "model_registry_access_level": "enabled", + "emails_disabled": false, + "emails_enabled": true, + "shared_runners_enabled": true, + "lfs_enabled": true, + "creator_id": 8814129, + "import_url": null, + "import_type": null, + "import_status": "none", + "import_error": null, + "open_issues_count": 1, + "description_html": "", + "updated_at": "2024-01-19T18:08:30.859Z", + "ci_default_git_depth": 50, + "ci_forward_deployment_enabled": true, + "ci_forward_deployment_rollback_allowed": true, + "ci_job_token_scope_enabled": false, + "ci_separated_caches": true, + "ci_allow_fork_pipelines_to_run_in_parent_project": true, + "build_git_strategy": "fetch", + "keep_latest_artifact": true, + "restrict_user_defined_variables": false, + "runners_token": "GR134894151j85TmuYJpzvNBypfaw", + "runner_token_expiration_interval": null, + "group_runners_enabled": true, + "auto_cancel_pending_pipelines": "enabled", + "build_timeout": 3600, + "auto_devops_enabled": false, + "auto_devops_deploy_strategy": "continuous", + "ci_config_path": "", + "public_jobs": true, + "shared_with_groups": [], + "only_allow_merge_if_pipeline_succeeds": false, + "allow_merge_on_skipped_pipeline": false, + "request_access_enabled": true, + "only_allow_merge_if_all_discussions_are_resolved": false, + "remove_source_branch_after_merge": true, + "printing_merge_request_link_enabled": true, + "merge_method": "merge", + "squash_option": "default_on", + "enforce_auth_checks_on_uploads": true, + "suggestion_commit_message": "", + "merge_commit_template": "", + "squash_commit_template": "", + "issue_branch_template": null, + "statistics": { + "commit_count": 5, + "storage_size": 88110, + "repository_size": 6782, + "wiki_size": 0, + "lfs_objects_size": 0, + "job_artifacts_size": 81328, + "pipeline_artifacts_size": 0, + "packages_size": 0, + "snippets_size": 0, + "uploads_size": 0 + }, + "warn_about_potentially_unwanted_characters": true, + "autoclose_referenced_issues": true, + "approvals_before_merge": 0, + "mirror": false, + "external_authorization_classification_label": "", + "marked_for_deletion_at": null, + "marked_for_deletion_on": null, + "requirements_enabled": true, + "requirements_access_level": "enabled", + "security_and_compliance_enabled": true, + "compliance_frameworks": [], + "issues_template": null, + "merge_requests_template": "", + "ci_restrict_pipeline_cancellation_role": "developer", + "merge_pipelines_enabled": false, + "merge_trains_enabled": false, + "merge_trains_skip_train_allowed": false, + "only_allow_merge_if_all_status_checks_passed": false, + "allow_pipeline_trigger_approve_deployment": false, + "prevent_merge_without_jira_issue": false, + "permissions": { + "project_access": { + "access_level": 50, + "notification_level": 3 + }, + "group_access": null + } + }, + "status": 200 + } + } +] diff --git a/test/json_output_data/project_view_result.json b/test/json_output_data/project_view_result.json new file mode 100644 index 000000000..927f4581f --- /dev/null +++ b/test/json_output_data/project_view_result.json @@ -0,0 +1 @@ +{"id":29316529,"description":"","default_branch":"main","public":false,"visibility":"public","ssh_url_to_repo":"git@gitlab.com:OWNER/REPO.git","http_url_to_repo":"https://gitlab.com/OWNER/REPO.git","web_url":"https://gitlab.com/OWNER/REPO","readme_url":"https://gitlab.com/OWNER/REPO/-/blob/main/README.md","tag_list":[],"topics":[],"owner":{"id":8814129,"username":"OWNER","email":"","name":"Some User","state":"active","web_url":"https://gitlab.com/OWNER","created_at":null,"bio":"","bot":false,"location":"","public_email":"","skype":"","linkedin":"","twitter":"","website_url":"","organization":"","job_title":"","extern_uid":"","provider":"","theme_id":0,"last_activity_on":null,"color_scheme_id":0,"is_admin":false,"avatar_url":"https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png","can_create_group":false,"can_create_project":false,"projects_limit":0,"current_sign_in_at":null,"current_sign_in_ip":null,"last_sign_in_at":null,"last_sign_in_ip":null,"confirmed_at":null,"two_factor_enabled":false,"note":"","identities":null,"external":false,"private_profile":false,"shared_runners_minutes_limit":0,"extra_shared_runners_minutes_limit":0,"using_license_seat":false,"custom_attributes":null,"namespace_id":0},"name":"REPO","name_with_namespace":"Some User / REPO","path":"REPO","path_with_namespace":"OWNER/REPO","issues_enabled":true,"open_issues_count":1,"merge_requests_enabled":true,"approvals_before_merge":0,"jobs_enabled":true,"wiki_enabled":true,"snippets_enabled":true,"resolve_outdated_diff_discussions":false,"container_expiration_policy":{"cadence":"1d","keep_n":10,"older_than":"90d","name_regex":".*","name_regex_delete":"","name_regex_keep":"","enabled":false,"next_run_at":"2021-09-03T13:38:42.834Z"},"container_registry_enabled":true,"container_registry_access_level":"enabled","container_registry_image_prefix":"registry.gitlab.com/OWNER/REPO","created_at":"2021-09-02T13:38:42.806Z","last_activity_at":"2022-01-20T21:11:56.564Z","creator_id":8814129,"namespace":{"id":11940376,"name":"Some User","path":"OWNER","kind":"user","full_path":"OWNER","parent_id":0,"avatar_url":"/uploads/-/system/user/avatar/8814129/avatar.png","web_url":"https://gitlab.com/OWNER"},"permissions":{"project_access":{"access_level":50,"notification_level":"global"},"group_access":null},"marked_for_deletion_at":null,"empty_repo":false,"archived":false,"avatar_url":"","license_url":"","license":null,"shared_runners_enabled":true,"group_runners_enabled":true,"runner_token_expiration_interval":0,"forks_count":0,"star_count":0,"runners_token":"GR134894151j85TmuYJpzvNBypfaw","allow_merge_on_skipped_pipeline":false,"only_allow_merge_if_pipeline_succeeds":false,"only_allow_merge_if_all_discussions_are_resolved":false,"remove_source_branch_after_merge":true,"printing_merge_request_link_enabled":true,"lfs_enabled":true,"repository_storage":"","request_access_enabled":true,"merge_method":"merge","can_create_merge_request_in":true,"forked_from_project":null,"mirror":false,"mirror_user_id":0,"mirror_trigger_builds":false,"only_mirror_protected_branches":false,"mirror_overwrites_diverged_branches":false,"packages_enabled":true,"service_desk_enabled":true,"service_desk_address":"contact-project+OWNER-REPO-29316529-issue-@incoming.gitlab.com","issues_access_level":"enabled","releases_access_level":"enabled","repository_access_level":"enabled","merge_requests_access_level":"enabled","forking_access_level":"enabled","wiki_access_level":"enabled","builds_access_level":"enabled","snippets_access_level":"enabled","pages_access_level":"enabled","operations_access_level":"","analytics_access_level":"enabled","environments_access_level":"enabled","feature_flags_access_level":"enabled","infrastructure_access_level":"enabled","monitor_access_level":"enabled","autoclose_referenced_issues":true,"suggestion_commit_message":"","squash_option":"default_on","enforce_auth_checks_on_uploads":true,"shared_with_groups":[],"statistics":{"commit_count":5,"storage_size":88110,"repository_size":6782,"wiki_size":0,"lfs_objects_size":0,"job_artifacts_size":81328,"pipeline_artifacts_size":0,"packages_size":0,"snippets_size":0,"uploads_size":0},"_links":{"self":"https://gitlab.com/api/v4/projects/29316529","issues":"https://gitlab.com/api/v4/projects/29316529/issues","merge_requests":"https://gitlab.com/api/v4/projects/29316529/merge_requests","repo_branches":"https://gitlab.com/api/v4/projects/29316529/repository/branches","labels":"https://gitlab.com/api/v4/projects/29316529/labels","events":"https://gitlab.com/api/v4/projects/29316529/events","members":"https://gitlab.com/api/v4/projects/29316529/members","cluster_agents":"https://gitlab.com/api/v4/projects/29316529/cluster_agents"},"import_url":"","import_type":"","import_status":"none","import_error":"","ci_default_git_depth":50,"ci_forward_deployment_enabled":true,"ci_separated_caches":true,"ci_job_token_scope_enabled":false,"ci_opt_in_jwt":false,"ci_allow_fork_pipelines_to_run_in_parent_project":true,"public_jobs":true,"build_timeout":3600,"auto_cancel_pending_pipelines":"enabled","ci_config_path":"","custom_attributes":null,"compliance_frameworks":[],"build_coverage_regex":"","issues_template":"","merge_requests_template":"","issue_branch_template":"","keep_latest_artifact":true,"merge_pipelines_enabled":false,"merge_trains_enabled":false,"restrict_user_defined_variables":false,"merge_commit_template":"","squash_commit_template":"","auto_devops_deploy_strategy":"continuous","auto_devops_enabled":false,"build_git_strategy":"fetch","emails_enabled":true,"external_authorization_classification_label":"","requirements_enabled":true,"requirements_access_level":"enabled","security_and_compliance_enabled":true,"security_and_compliance_access_level":"private","mr_default_target_self":false,"emails_disabled":false,"public_builds":false} diff --git a/test/json_output_data/variable_get.json b/test/json_output_data/variable_get.json new file mode 100644 index 000000000..a177a2379 --- /dev/null +++ b/test/json_output_data/variable_get.json @@ -0,0 +1,21 @@ +[ + { + "request": { + "url": "/api/v4/projects/OWNER%2FREPO/variables/PROJECT_VAR?filter%5Benvironment_scope%5D=%2A", + "method": "GET" + }, + "response": { + "body": { + "variable_type": "env_var", + "key": "PROJECT_VAR", + "value": "project", + "protected": false, + "masked": false, + "raw": false, + "environment_scope": "*", + "description": null + }, + "status": 200 + } + } +] diff --git a/test/json_output_data/variable_get_result.json b/test/json_output_data/variable_get_result.json new file mode 100644 index 000000000..836245f17 --- /dev/null +++ b/test/json_output_data/variable_get_result.json @@ -0,0 +1 @@ +{"key":"PROJECT_VAR","value":"project","variable_type":"env_var","protected":false,"masked":false,"raw":false,"environment_scope":"*"} diff --git a/test/json_output_data/variable_list.json b/test/json_output_data/variable_list.json new file mode 100644 index 000000000..02aedd00c --- /dev/null +++ b/test/json_output_data/variable_list.json @@ -0,0 +1,23 @@ +[ + { + "request": { + "url": "/api/v4/projects/OWNER%2FREPO/variables", + "method": "GET" + }, + "response": { + "body": [ + { + "variable_type": "env_var", + "key": "PROJECT_VAR", + "value": "project", + "protected": false, + "masked": false, + "raw": false, + "environment_scope": "*", + "description": null + } + ], + "status": 200 + } + } +] diff --git a/test/json_output_data/variable_list_result.json b/test/json_output_data/variable_list_result.json new file mode 100644 index 000000000..900d5c6d9 --- /dev/null +++ b/test/json_output_data/variable_list_result.json @@ -0,0 +1 @@ +[{"key":"PROJECT_VAR","value":"project","variable_type":"env_var","protected":false,"masked":false,"raw":false,"environment_scope":"*"}] -- GitLab From 7d6762e87107d78063cb87f27eaf821cc4450119 Mon Sep 17 00:00:00 2001 From: Dmitry Makovey Date: Tue, 13 Feb 2024 12:07:48 -0800 Subject: [PATCH 03/15] Update documentation --- commands/ci/get/get.go | 4 ++-- commands/ci/list/list.go | 4 ++-- commands/issuable/list/issuable_list.go | 2 +- commands/issuable/view/issuable_view.go | 2 +- commands/label/list/label_list.go | 2 +- commands/mr/list/mr_list.go | 2 +- commands/mr/view/mr_view.go | 2 +- commands/project/list/list.go | 2 +- commands/project/view/project_view.go | 2 +- commands/variable/get/get.go | 2 +- commands/variable/list/list.go | 2 +- docs/source/ci/get.md | 10 +++++----- docs/source/ci/list.md | 12 ++++++------ docs/source/incident/list.md | 2 +- docs/source/incident/view.md | 12 ++++++------ docs/source/issue/list.md | 2 +- docs/source/issue/view.md | 12 ++++++------ docs/source/label/list.md | 6 +++--- docs/source/mr/list.md | 2 +- docs/source/mr/view.md | 12 ++++++------ docs/source/repo/list.md | 20 ++++++++++---------- docs/source/repo/view.md | 6 +++--- docs/source/variable/get.md | 6 +++--- docs/source/variable/list.md | 6 +++--- 24 files changed, 67 insertions(+), 67 deletions(-) diff --git a/commands/ci/get/get.go b/commands/ci/get/get.go index 5725b38d4..f8b2676fd 100644 --- a/commands/ci/get/get.go +++ b/commands/ci/get/get.go @@ -94,7 +94,7 @@ func NewCmdGet(f *cmdutils.Factory) *cobra.Command { Variables: variables, } - outputFormat, _ := cmd.Flags().GetString("output-format") + outputFormat, _ := cmd.Flags().GetString("output") if outputFormat == "json" { printJSON(*mergedPipelineObject, f.IO.StdOut) } else { @@ -108,7 +108,7 @@ func NewCmdGet(f *cmdutils.Factory) *cobra.Command { pipelineGetCmd.Flags().StringP("branch", "b", "", "Check pipeline status for a branch. (Default is current branch)") pipelineGetCmd.Flags().IntP("pipeline-id", "p", 0, "Provide pipeline ID") - pipelineGetCmd.Flags().StringP("output-format", "F", "text", "Format output as: text, json") + pipelineGetCmd.Flags().StringP("output", "F", "text", "Format output as: text, json") pipelineGetCmd.Flags().BoolP("with-job-details", "d", false, "Show extended job information") pipelineGetCmd.Flags().Bool("with-variables", false, "Show variables in pipeline (maintainer role required)") diff --git a/commands/ci/list/list.go b/commands/ci/list/list.go index 6718aaea2..46b4772f9 100644 --- a/commands/ci/list/list.go +++ b/commands/ci/list/list.go @@ -40,7 +40,7 @@ func NewCmdList(f *cmdutils.Factory) *cobra.Command { l := &gitlab.ListProjectPipelinesOptions{} - format, _ := cmd.Flags().GetString("output-format") + format, _ := cmd.Flags().GetString("output") jsonOut := format == "json" l.Page = 1 @@ -87,7 +87,7 @@ func NewCmdList(f *cmdutils.Factory) *cobra.Command { pipelineListCmd.Flags().StringP("sort", "", "desc", "Sort pipeline by {asc|desc}") pipelineListCmd.Flags().IntP("page", "p", 1, "Page number") pipelineListCmd.Flags().IntP("per-page", "P", 30, "Number of items to list per page") - pipelineListCmd.Flags().StringP("output-format", "F", "text", "Format output as: text, json") + pipelineListCmd.Flags().StringP("output", "F", "text", "Format output as: text, json") return pipelineListCmd } diff --git a/commands/issuable/list/issuable_list.go b/commands/issuable/list/issuable_list.go index c25c7d80f..bd09d0706 100644 --- a/commands/issuable/list/issuable_list.go +++ b/commands/issuable/list/issuable_list.go @@ -138,7 +138,7 @@ func NewCmdList(f *cmdutils.Factory, runE func(opts *ListOptions) error, issueTy issueListCmd.Flags().BoolVarP(&opts.All, "all", "A", false, fmt.Sprintf("Get all %ss", issueType)) issueListCmd.Flags().BoolVarP(&opts.Closed, "closed", "c", false, fmt.Sprintf("Get only closed %ss", issueType)) issueListCmd.Flags().BoolVarP(&opts.Confidential, "confidential", "C", false, fmt.Sprintf("Filter by confidential %ss", issueType)) - issueListCmd.Flags().StringVarP(&opts.OutputFormat, "output-format", "F", "details", "One of 'details', 'ids', 'urls' or 'json'") + issueListCmd.Flags().StringVarP(&opts.OutputFormat, "output", "F", "details", "One of 'details', 'ids', 'urls' or 'json'") issueListCmd.Flags().IntVarP(&opts.Page, "page", "p", 1, "Page number") issueListCmd.Flags().IntVarP(&opts.PerPage, "per-page", "P", 30, "Number of items to list per page.") issueListCmd.PersistentFlags().StringP("group", "g", "", "Select a group/subgroup. This option is ignored if a repo argument is set.") diff --git a/commands/issuable/view/issuable_view.go b/commands/issuable/view/issuable_view.go index 4fff440d7..ecb18ef87 100644 --- a/commands/issuable/view/issuable_view.go +++ b/commands/issuable/view/issuable_view.go @@ -131,7 +131,7 @@ func NewCmdView(f *cmdutils.Factory, issueType issuable.IssueType) *cobra.Comman issueViewCmd.Flags().BoolVarP(&opts.Web, "web", "w", false, fmt.Sprintf("Open %s in a browser. Uses default browser or browser specified in BROWSER variable", issueType)) issueViewCmd.Flags().IntVarP(&opts.CommentPageNumber, "page", "p", 1, "Page number") issueViewCmd.Flags().IntVarP(&opts.CommentLimit, "per-page", "P", 20, "Number of items to list per page") - issueViewCmd.Flags().StringVarP(&opts.OutputFormat, "output-format", "F", "text", "Format output as: text, json") + issueViewCmd.Flags().StringVarP(&opts.OutputFormat, "output", "F", "text", "Format output as: text, json") return issueViewCmd } diff --git a/commands/label/list/label_list.go b/commands/label/list/label_list.go index 63c4c6c2d..c209596f0 100644 --- a/commands/label/list/label_list.go +++ b/commands/label/list/label_list.go @@ -90,7 +90,7 @@ func NewCmdList(f *cmdutils.Factory) *cobra.Command { labelListCmd.Flags().IntP("page", "p", 1, "Page number") labelListCmd.Flags().IntP("per-page", "P", 30, "Number of items to list per page") - labelListCmd.Flags().StringVarP(&OutputFormat, "output-format", "F", "text", "Format output as: text, json") + labelListCmd.Flags().StringVarP(&OutputFormat, "output", "F", "text", "Format output as: text, json") return labelListCmd } diff --git a/commands/mr/list/mr_list.go b/commands/mr/list/mr_list.go index fbb608584..741d01114 100644 --- a/commands/mr/list/mr_list.go +++ b/commands/mr/list/mr_list.go @@ -134,7 +134,7 @@ func NewCmdList(f *cmdutils.Factory, runE func(opts *ListOptions) error) *cobra. mrListCmd.Flags().BoolVarP(&opts.Closed, "closed", "c", false, "Get only closed merge requests") mrListCmd.Flags().BoolVarP(&opts.Merged, "merged", "M", false, "Get only merged merge requests") mrListCmd.Flags().BoolVarP(&opts.Draft, "draft", "d", false, "Filter by draft merge requests") - mrListCmd.Flags().StringVarP(&opts.OutputFormat, "output-format", "F", "text", "Format output as: text, json") + mrListCmd.Flags().StringVarP(&opts.OutputFormat, "output", "F", "text", "Format output as: text, json") mrListCmd.Flags().IntVarP(&opts.Page, "page", "p", 1, "Page number") mrListCmd.Flags().IntVarP(&opts.PerPage, "per-page", "P", 30, "Number of items to list per page") mrListCmd.Flags().StringSliceVarP(&opts.Assignee, "assignee", "a", []string{}, "Get only merge requests assigned to users") diff --git a/commands/mr/view/mr_view.go b/commands/mr/view/mr_view.go index bbfe18172..deed06d26 100644 --- a/commands/mr/view/mr_view.go +++ b/commands/mr/view/mr_view.go @@ -115,7 +115,7 @@ func NewCmdView(f *cmdutils.Factory) *cobra.Command { mrViewCmd.Flags().BoolVarP(&opts.ShowComments, "comments", "c", false, "Show mr comments and activities") mrViewCmd.Flags().BoolVarP(&opts.ShowSystemLogs, "system-logs", "s", false, "Show system activities / logs") - mrViewCmd.Flags().StringVarP(&opts.OutputFormat, "output-format", "F", "text", "Format output as: text, json") + mrViewCmd.Flags().StringVarP(&opts.OutputFormat, "output", "F", "text", "Format output as: text, json") mrViewCmd.Flags().BoolVarP(&opts.OpenInBrowser, "web", "w", false, "Open mr in a browser. Uses default browser or browser specified in BROWSER variable") mrViewCmd.Flags().IntVarP(&opts.CommentPageNumber, "page", "p", 0, "Page number") mrViewCmd.Flags().IntVarP(&opts.CommentLimit, "per-page", "P", 20, "Number of items to list per page") diff --git a/commands/project/list/list.go b/commands/project/list/list.go index 947b03729..e59c718a9 100644 --- a/commands/project/list/list.go +++ b/commands/project/list/list.go @@ -53,7 +53,7 @@ func NewCmdList(f *cmdutils.Factory) *cobra.Command { repoListCmd.Flags().StringVarP(&opts.Group, "group", "g", "", "Return only repositories in the given group and its subgroups") repoListCmd.Flags().IntVarP(&opts.Page, "page", "p", 1, "Page number") repoListCmd.Flags().IntVarP(&opts.PerPage, "per-page", "P", 30, "Number of items to list per page") - repoListCmd.Flags().StringVarP(&opts.OutputFormat, "output-format", "F", "text", "Format output as: text, json") + repoListCmd.Flags().StringVarP(&opts.OutputFormat, "output", "F", "text", "Format output as: text, json") repoListCmd.Flags().BoolVarP(&opts.FilterAll, "all", "a", false, "List all projects on the instance") repoListCmd.Flags().BoolVarP(&opts.FilterOwned, "mine", "m", false, "Only list projects you own (default if no filters are passed)") repoListCmd.Flags().BoolVar(&opts.FilterMember, "member", false, "Only list projects which you are a member") diff --git a/commands/project/view/project_view.go b/commands/project/view/project_view.go index d4d55c82a..480dc9204 100644 --- a/commands/project/view/project_view.go +++ b/commands/project/view/project_view.go @@ -122,7 +122,7 @@ func NewCmdView(f *cmdutils.Factory) *cobra.Command { } projectViewCmd.Flags().BoolVarP(&opts.Web, "web", "w", false, "Open a project in the browser") - projectViewCmd.Flags().StringVarP(&opts.OutputFormat, "output-format", "F", "text", "Format output as: text, json") + projectViewCmd.Flags().StringVarP(&opts.OutputFormat, "output", "F", "text", "Format output as: text, json") projectViewCmd.Flags().StringVarP(&opts.Branch, "branch", "b", "", "View a specific branch of the repository") return projectViewCmd diff --git a/commands/variable/get/get.go b/commands/variable/get/get.go index c2a9d9116..5532e3abd 100644 --- a/commands/variable/get/get.go +++ b/commands/variable/get/get.go @@ -68,7 +68,7 @@ func NewCmdSet(f *cmdutils.Factory, runE func(opts *GetOps) error) *cobra.Comman cmd.Flags().StringVarP(&opts.Scope, "scope", "s", "*", "The environment_scope of the variable. All (*), or specific environments.") cmd.Flags().StringVarP(&opts.Group, "group", "g", "", "Get variable for a group") - cmd.Flags().StringVarP(&opts.OutputFormat, "output-format", "F", "text", "Format output as: text, json") + cmd.Flags().StringVarP(&opts.OutputFormat, "output", "F", "text", "Format output as: text, json") return cmd } diff --git a/commands/variable/list/list.go b/commands/variable/list/list.go index f738e7e7a..dbcc1cb91 100644 --- a/commands/variable/list/list.go +++ b/commands/variable/list/list.go @@ -68,7 +68,7 @@ func NewCmdSet(f *cmdutils.Factory, runE func(opts *ListOpts) error) *cobra.Comm "", "Select a group/subgroup. This option is ignored if a repo argument is set.", ) - cmd.Flags().StringVarP(&opts.OutputFormat, "output-format", "F", "text", "Format output as: text, json") + cmd.Flags().StringVarP(&opts.OutputFormat, "output", "F", "text", "Format output as: text, json") return cmd } diff --git a/docs/source/ci/get.md b/docs/source/ci/get.md index d3af706fe..898441adb 100644 --- a/docs/source/ci/get.md +++ b/docs/source/ci/get.md @@ -34,11 +34,11 @@ glab ci -R some/project -p 12345 ## Options ```plaintext - -b, --branch string Check pipeline status for a branch. (Default is current branch) - -F, --output-format string Format output as: text, json (default "text") - -p, --pipeline-id int Provide pipeline ID - -d, --with-job-details Show extended job information - --with-variables Show variables in pipeline (maintainer role required) + -b, --branch string Check pipeline status for a branch. (Default is current branch) + -F, --output string Format output as: text, json (default "text") + -p, --pipeline-id int Provide pipeline ID + -d, --with-job-details Show extended job information + --with-variables Show variables in pipeline (maintainer role required) ``` ## Options inherited from parent commands diff --git a/docs/source/ci/list.md b/docs/source/ci/list.md index 0480cf995..dcbf24fb3 100644 --- a/docs/source/ci/list.md +++ b/docs/source/ci/list.md @@ -28,12 +28,12 @@ glab ci list --status=failed ## Options ```plaintext - -o, --orderBy string Order pipeline by {id|status|ref|updated_at|user_id} (default "id") - -F, --output-format string Format output as: text, json (default "text") - -p, --page int Page number (default 1) - -P, --per-page int Number of items to list per page (default 30) - --sort string Sort pipeline by {asc|desc} (default "desc") - -s, --status string Get pipeline with status: {running|pending|success|failed|canceled|skipped|created|manual|waiting_for_resource|preparing|scheduled} + -o, --orderBy string Order pipeline by {id|status|ref|updated_at|user_id} (default "id") + -F, --output string Format output as: text, json (default "text") + -p, --page int Page number (default 1) + -P, --per-page int Number of items to list per page (default 30) + --sort string Sort pipeline by {asc|desc} (default "desc") + -s, --status string Get pipeline with status: {running|pending|success|failed|canceled|skipped|created|manual|waiting_for_resource|preparing|scheduled} ``` ## Options inherited from parent commands diff --git a/docs/source/incident/list.md b/docs/source/incident/list.md index 6188f7650..01b352608 100644 --- a/docs/source/incident/list.md +++ b/docs/source/incident/list.md @@ -48,7 +48,7 @@ glab incident list --milestone release-2.0.0 --opened --not-assignee strings Filter incident by not being assigneed to --not-author strings Filter by not being by author(s) --not-label strings Filter incident by lack of label - -F, --output-format string One of 'details', 'ids', 'urls' or 'json' (default "details") + -F, --output string One of 'details', 'ids', 'urls' or 'json' (default "details") -p, --page int Page number (default 1) -P, --per-page int Number of items to list per page. (default 30) -R, --repo OWNER/REPO Select another repository using the OWNER/REPO or `GROUP/NAMESPACE/REPO` format or full URL or git URL diff --git a/docs/source/incident/view.md b/docs/source/incident/view.md index 377c12be7..3e1d0e6de 100644 --- a/docs/source/incident/view.md +++ b/docs/source/incident/view.md @@ -37,12 +37,12 @@ glab incident view https://gitlab.com/NAMESPACE/REPO/-/issues/incident/123 ## Options ```plaintext - -c, --comments Show incident comments and activities - -F, --output-format string Format output as: text, json (default "text") - -p, --page int Page number (default 1) - -P, --per-page int Number of items to list per page (default 20) - -s, --system-logs Show system activities / logs - -w, --web Open incident in a browser. Uses default browser or browser specified in BROWSER variable + -c, --comments Show incident comments and activities + -F, --output string Format output as: text, json (default "text") + -p, --page int Page number (default 1) + -P, --per-page int Number of items to list per page (default 20) + -s, --system-logs Show system activities / logs + -w, --web Open incident in a browser. Uses default browser or browser specified in BROWSER variable ``` ## Options inherited from parent commands diff --git a/docs/source/issue/list.md b/docs/source/issue/list.md index ab0e1276a..2682e55d0 100644 --- a/docs/source/issue/list.md +++ b/docs/source/issue/list.md @@ -49,7 +49,7 @@ glab issue list --milestone release-2.0.0 --opened --not-assignee strings Filter issue by not being assigneed to --not-author strings Filter by not being by author(s) --not-label strings Filter issue by lack of label - -F, --output-format string One of 'details', 'ids', 'urls' or 'json' (default "details") + -F, --output string One of 'details', 'ids', 'urls' or 'json' (default "details") -p, --page int Page number (default 1) -P, --per-page int Number of items to list per page. (default 30) -R, --repo OWNER/REPO Select another repository using the OWNER/REPO or `GROUP/NAMESPACE/REPO` format or full URL or git URL diff --git a/docs/source/issue/view.md b/docs/source/issue/view.md index 9286b3969..051a8906f 100644 --- a/docs/source/issue/view.md +++ b/docs/source/issue/view.md @@ -37,12 +37,12 @@ glab issue view https://gitlab.com/NAMESPACE/REPO/-/issues/123 ## Options ```plaintext - -c, --comments Show issue comments and activities - -F, --output-format string Format output as: text, json (default "text") - -p, --page int Page number (default 1) - -P, --per-page int Number of items to list per page (default 20) - -s, --system-logs Show system activities / logs - -w, --web Open issue in a browser. Uses default browser or browser specified in BROWSER variable + -c, --comments Show issue comments and activities + -F, --output string Format output as: text, json (default "text") + -p, --page int Page number (default 1) + -P, --per-page int Number of items to list per page (default 20) + -s, --system-logs Show system activities / logs + -w, --web Open issue in a browser. Uses default browser or browser specified in BROWSER variable ``` ## Options inherited from parent commands diff --git a/docs/source/label/list.md b/docs/source/label/list.md index 8a254d6bb..d5bacda8c 100644 --- a/docs/source/label/list.md +++ b/docs/source/label/list.md @@ -35,9 +35,9 @@ glab label list -R owner/repository ## Options ```plaintext - -F, --output-format string Format output as: text, json (default "text") - -p, --page int Page number (default 1) - -P, --per-page int Number of items to list per page (default 30) + -F, --output string Format output as: text, json (default "text") + -p, --page int Page number (default 1) + -P, --per-page int Number of items to list per page (default 30) ``` ## Options inherited from parent commands diff --git a/docs/source/mr/list.md b/docs/source/mr/list.md index 2b88c057f..9481889da 100644 --- a/docs/source/mr/list.md +++ b/docs/source/mr/list.md @@ -52,7 +52,7 @@ glab mr list -M --per-page 10 -M, --merged Get only merged merge requests -m, --milestone string Filter merge request by milestone --not-label strings Filter merge requests by not having label - -F, --output-format string Format output as: text, json (default "text") + -F, --output string Format output as: text, json (default "text") -p, --page int Page number (default 1) -P, --per-page int Number of items to list per page (default 30) -R, --repo OWNER/REPO Select another repository using the OWNER/REPO or `GROUP/NAMESPACE/REPO` format or full URL or git URL diff --git a/docs/source/mr/view.md b/docs/source/mr/view.md index 1dd61938a..bc4b2e5df 100644 --- a/docs/source/mr/view.md +++ b/docs/source/mr/view.md @@ -26,12 +26,12 @@ show ## Options ```plaintext - -c, --comments Show mr comments and activities - -F, --output-format string Format output as: text, json (default "text") - -p, --page int Page number - -P, --per-page int Number of items to list per page (default 20) - -s, --system-logs Show system activities / logs - -w, --web Open mr in a browser. Uses default browser or browser specified in BROWSER variable + -c, --comments Show mr comments and activities + -F, --output string Format output as: text, json (default "text") + -p, --page int Page number + -P, --per-page int Number of items to list per page (default 20) + -s, --system-logs Show system activities / logs + -w, --web Open mr in a browser. Uses default browser or browser specified in BROWSER variable ``` ## Options inherited from parent commands diff --git a/docs/source/repo/list.md b/docs/source/repo/list.md index cfc73d227..2fbfdc0ff 100644 --- a/docs/source/repo/list.md +++ b/docs/source/repo/list.md @@ -33,16 +33,16 @@ glab repo list ## Options ```plaintext - -a, --all List all projects on the instance - -g, --group string Return only repositories in the given group and its subgroups - --member Only list projects which you are a member - -m, --mine Only list projects you own (default if no filters are passed) - -o, --order string Return repositories ordered by id, created_at, or other fields (default "last_activity_at") - -F, --output-format string Format output as: text, json (default "text") - -p, --page int Page number (default 1) - -P, --per-page int Number of items to list per page (default 30) - -s, --sort string Return repositories sorted in asc or desc order - --starred Only list starred projects + -a, --all List all projects on the instance + -g, --group string Return only repositories in the given group and its subgroups + --member Only list projects which you are a member + -m, --mine Only list projects you own (default if no filters are passed) + -o, --order string Return repositories ordered by id, created_at, or other fields (default "last_activity_at") + -F, --output string Format output as: text, json (default "text") + -p, --page int Page number (default 1) + -P, --per-page int Number of items to list per page (default 30) + -s, --sort string Return repositories sorted in asc or desc order + --starred Only list starred projects ``` ## Options inherited from parent commands diff --git a/docs/source/repo/view.md b/docs/source/repo/view.md index a15a636f4..cb24b58dd 100644 --- a/docs/source/repo/view.md +++ b/docs/source/repo/view.md @@ -42,9 +42,9 @@ $ glab repo view https://gitlab.company.org/user/repo.git ## Options ```plaintext - -b, --branch string View a specific branch of the repository - -F, --output-format string Format output as: text, json (default "text") - -w, --web Open a project in the browser + -b, --branch string View a specific branch of the repository + -F, --output string Format output as: text, json (default "text") + -w, --web Open a project in the browser ``` ## Options inherited from parent commands diff --git a/docs/source/variable/get.md b/docs/source/variable/get.md index 6b33648c2..71eee592e 100644 --- a/docs/source/variable/get.md +++ b/docs/source/variable/get.md @@ -29,9 +29,9 @@ glab variable get -s SCOPE VAR_KEY ## Options ```plaintext - -g, --group string Get variable for a group - -F, --output-format string Format output as: text, json (default "text") - -s, --scope string The environment_scope of the variable. All (*), or specific environments. (default "*") + -g, --group string Get variable for a group + -F, --output string Format output as: text, json (default "text") + -s, --scope string The environment_scope of the variable. All (*), or specific environments. (default "*") ``` ## Options inherited from parent commands diff --git a/docs/source/variable/list.md b/docs/source/variable/list.md index 11cad4344..69b0f165b 100644 --- a/docs/source/variable/list.md +++ b/docs/source/variable/list.md @@ -33,9 +33,9 @@ glab variable list ## Options ```plaintext - -g, --group string Select a group/subgroup. This option is ignored if a repo argument is set. - -F, --output-format string Format output as: text, json (default "text") - -R, --repo OWNER/REPO Select another repository using the OWNER/REPO or `GROUP/NAMESPACE/REPO` format or full URL or git URL + -g, --group string Select a group/subgroup. This option is ignored if a repo argument is set. + -F, --output string Format output as: text, json (default "text") + -R, --repo OWNER/REPO Select another repository using the OWNER/REPO or `GROUP/NAMESPACE/REPO` format or full URL or git URL ``` ## Options inherited from parent commands -- GitLab From 143769971facd001ff3232c6713594a3d99686e3 Mon Sep 17 00:00:00 2001 From: Dmitry Makovey Date: Tue, 13 Feb 2024 13:57:57 -0800 Subject: [PATCH 04/15] address lint issues --- commands/ci/get/get_test.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/commands/ci/get/get_test.go b/commands/ci/get/get_test.go index e96df2b10..518f1425c 100644 --- a/commands/ci/get/get_test.go +++ b/commands/ci/get/get_test.go @@ -118,12 +118,14 @@ updated: 2023-10-10 00:00:00 +0000 UTC "started_at": "2023-10-10T00:00:00Z", "updated_at": "2023-10-10T00:00:00Z" }`, + INLINE_BODY, }, { http.MethodGet, "/api/v4/projects/OWNER%2FREPO/pipelines/123/jobs?per_page=100", http.StatusOK, `[]`, + INLINE_BODY, }, { http.MethodGet, @@ -134,6 +136,7 @@ updated: 2023-10-10 00:00:00 +0000 UTC "id": 123 } }`, + INLINE_BODY, }, }, expectedOut: `# Pipeline: @@ -176,6 +179,7 @@ updated: 2023-10-10 00:00:00 +0000 UTC "started_at": "2023-10-10T00:00:00Z", "updated_at": "2023-10-10T00:00:00Z" }`, + INLINE_BODY, }, { http.MethodGet, @@ -186,6 +190,7 @@ updated: 2023-10-10 00:00:00 +0000 UTC "name": "publish", "status": "failed" }]`, + INLINE_BODY, }, }, expectedOut: `# Pipeline: @@ -229,6 +234,7 @@ publish: failed "started_at": "2023-10-10T00:00:00Z", "updated_at": "2023-10-10T00:00:00Z" }`, + INLINE_BODY, }, { http.MethodGet, @@ -240,6 +246,7 @@ publish: failed "status": "failed", "failure_reason": "bad timing" }]`, + INLINE_BODY, }, }, expectedOut: `# Pipeline: -- GitLab From fe3aae4eaecdcbb091fc20509dbaf0f054c0d2cf Mon Sep 17 00:00:00 2001 From: Dmitry Makovey Date: Tue, 13 Feb 2024 14:39:02 -0800 Subject: [PATCH 05/15] Satisfy lint requirements --- commands/ci/get/get_test.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/commands/ci/get/get_test.go b/commands/ci/get/get_test.go index 518f1425c..41919fac3 100644 --- a/commands/ci/get/get_test.go +++ b/commands/ci/get/get_test.go @@ -26,8 +26,10 @@ func runCommand(rt http.RoundTripper, isTTY bool, args string) (*test.CmdOut, er return cmdtest.ExecuteCommand(cmd, args, stdout, stderr) } -const FILE_BODY = 1 -const INLINE_BODY = 2 +const ( + FILE_BODY = 1 + INLINE_BODY = 2 +) func TestCIGet(t *testing.T) { type httpMock struct { @@ -432,8 +434,10 @@ No variables found in pipeline. require.Nil(t, err) fmt.Printf("++>> %s\n", output.String()) - os.WriteFile("/tmp/expected", []byte(tc.expectedOut), 0644) - os.WriteFile("/tmp/received", []byte(output.String()), 0644) + err = os.WriteFile("/tmp/expected", []byte(tc.expectedOut), 0o644) + require.Nil(t, err) + err = os.WriteFile("/tmp/received", []byte(output.String()), 0o644) + require.Nil(t, err) assert.Equal(t, tc.expectedOut, output.String()) assert.Empty(t, output.Stderr()) }) -- GitLab From 8d8dead91ce19fd8c63cf09f9e59ef1e6e4716b7 Mon Sep 17 00:00:00 2001 From: Dmitry Makovey Date: Tue, 13 Feb 2024 15:35:31 -0800 Subject: [PATCH 06/15] Wired test data into the actual tests --- commands/ci/get/testdata/ci_get-0.json | 51 ++++++++++ commands/ci/get/testdata/ci_get-0.request | 4 + commands/ci/get/testdata/ci_get-1.json | 111 ++++++++++++++++++++++ commands/ci/get/testdata/ci_get-1.request | 4 + commands/ci/get/testdata/ci_get.result | 1 + 5 files changed, 171 insertions(+) create mode 100644 commands/ci/get/testdata/ci_get-0.json create mode 100644 commands/ci/get/testdata/ci_get-0.request create mode 100644 commands/ci/get/testdata/ci_get-1.json create mode 100644 commands/ci/get/testdata/ci_get-1.request create mode 100644 commands/ci/get/testdata/ci_get.result diff --git a/commands/ci/get/testdata/ci_get-0.json b/commands/ci/get/testdata/ci_get-0.json new file mode 100644 index 000000000..2a6cd2250 --- /dev/null +++ b/commands/ci/get/testdata/ci_get-0.json @@ -0,0 +1,51 @@ +{ + "request": { + "url": "/api/v4/projects/OWNER%2FREPO/pipelines/452959326", + "method": "GET" + }, + "response": { + "body": { + "id": 452959326, + "iid": 14, + "project_id": 29316529, + "sha": "44eb489568f7cb1a5a730fce6b247cd3797172ca", + "ref": "1-fake-issue-3", + "status": "success", + "source": "push", + "created_at": "2022-01-20T21:47:16.276Z", + "updated_at": "2022-01-20T21:47:31.358Z", + "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/452959326", + "before_sha": "001eb421e586a3f07f90aea102c8b2d4068ab5b6", + "tag": false, + "yaml_errors": null, + "user": { + "id": 8814129, + "username": "OWNER", + "name": "Some User", + "state": "active", + "locked": false, + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", + "web_url": "https://gitlab.com/OWNER" + }, + "started_at": "2022-01-20T21:47:17.448Z", + "finished_at": "2022-01-20T21:47:31.350Z", + "committed_at": null, + "duration": 14, + "queued_duration": 1, + "coverage": null, + "detailed_status": { + "icon": "status_success", + "text": "Passed", + "label": "passed", + "group": "success", + "tooltip": "passed", + "has_details": true, + "details_path": "/OWNER/REPO/-/pipelines/452959326", + "illustration": null, + "favicon": "/assets/ci_favicons/favicon_status_success-8451333011eee8ce9f2ab25dc487fe24a8758c694827a582f17f42b0a90446a2.png" + }, + "name": null + }, + "status": 200 + } +} diff --git a/commands/ci/get/testdata/ci_get-0.request b/commands/ci/get/testdata/ci_get-0.request new file mode 100644 index 000000000..0d1edd5a6 --- /dev/null +++ b/commands/ci/get/testdata/ci_get-0.request @@ -0,0 +1,4 @@ +{ + "url": "/api/v4/projects/OWNER%2FREPO/pipelines/452959326", + "method": "GET" +} diff --git a/commands/ci/get/testdata/ci_get-1.json b/commands/ci/get/testdata/ci_get-1.json new file mode 100644 index 000000000..44b071531 --- /dev/null +++ b/commands/ci/get/testdata/ci_get-1.json @@ -0,0 +1,111 @@ +{ + "request": { + "url": "/api/v4/projects/OWNER%2FREPO/pipelines/452959326/jobs?per_page=100", + "method": "GET" + }, + "response": { + "body": [ + { + "id": 1999017704, + "status": "success", + "stage": "test", + "name": "test_vars", + "ref": "1-fake-issue-3", + "tag": false, + "coverage": null, + "allow_failure": false, + "created_at": "2022-01-20T21:47:16.291Z", + "started_at": "2022-01-20T21:47:16.693Z", + "finished_at": "2022-01-20T21:47:31.274Z", + "erased_at": null, + "duration": 14.580467, + "queued_duration": 0.211715, + "user": { + "id": 8814129, + "username": "OWNER", + "name": "Some User", + "state": "active", + "locked": false, + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", + "web_url": "https://gitlab.com/OWNER", + "created_at": "2021-05-03T14:58:50.059Z", + "bio": "", + "location": "Canada", + "public_email": "", + "skype": "", + "linkedin": "", + "twitter": "", + "discord": "", + "website_url": "", + "organization": "GitLab", + "job_title": "Sr Backend Engineer", + "pronouns": "", + "bot": false, + "work_information": "Sr Backend Engineer at GitLab", + "followers": 2, + "following": 0, + "local_time": "3:30 PM" + }, + "commit": { + "id": "44eb489568f7cb1a5a730fce6b247cd3797172ca", + "short_id": "44eb4895", + "created_at": "2022-01-20T21:47:15.000+00:00", + "parent_ids": [ + "001eb421e586a3f07f90aea102c8b2d4068ab5b6" + ], + "title": "Add new file", + "message": "Add new file", + "author_name": "Some User", + "author_email": "OWNER@gitlab.com", + "authored_date": "2022-01-20T21:47:15.000+00:00", + "committer_name": "Some User", + "committer_email": "OWNER@gitlab.com", + "committed_date": "2022-01-20T21:47:15.000+00:00", + "trailers": {}, + "extended_trailers": {}, + "web_url": "https://gitlab.com/OWNER/REPO/-/commit/44eb489568f7cb1a5a730fce6b247cd3797172ca" + }, + "pipeline": { + "id": 452959326, + "iid": 14, + "project_id": 29316529, + "sha": "44eb489568f7cb1a5a730fce6b247cd3797172ca", + "ref": "1-fake-issue-3", + "status": "success", + "source": "push", + "created_at": "2022-01-20T21:47:16.276Z", + "updated_at": "2022-01-20T21:47:31.358Z", + "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/452959326" + }, + "web_url": "https://gitlab.com/OWNER/REPO/-/jobs/1999017704", + "project": { + "ci_job_token_scope_enabled": false + }, + "artifacts": [ + { + "file_type": "trace", + "size": 2770, + "filename": "job.log", + "file_format": null + } + ], + "runner": { + "id": 12270859, + "description": "5-green.saas-linux-small-amd64.runners-manager.gitlab.com/default", + "ip_address": "10.1.5.249", + "active": true, + "paused": false, + "is_shared": true, + "runner_type": "instance_type", + "name": "gitlab-runner", + "online": false, + "status": "offline" + }, + "artifacts_expire_at": null, + "archived": false, + "tag_list": [] + } + ], + "status": 200 + } +} diff --git a/commands/ci/get/testdata/ci_get-1.request b/commands/ci/get/testdata/ci_get-1.request new file mode 100644 index 000000000..d9ad0906a --- /dev/null +++ b/commands/ci/get/testdata/ci_get-1.request @@ -0,0 +1,4 @@ +{ + "url": "/api/v4/projects/OWNER%2FREPO/pipelines/452959326/jobs?per_page=100", + "method": "GET" +} diff --git a/commands/ci/get/testdata/ci_get.result b/commands/ci/get/testdata/ci_get.result new file mode 100644 index 000000000..f997aec80 --- /dev/null +++ b/commands/ci/get/testdata/ci_get.result @@ -0,0 +1 @@ +{"id":452959326,"iid":14,"project_id":29316529,"status":"success","source":"push","ref":"1-fake-issue-3","sha":"44eb489568f7cb1a5a730fce6b247cd3797172ca","before_sha":"001eb421e586a3f07f90aea102c8b2d4068ab5b6","tag":false,"yaml_errors":"","user":{"id":8814129,"username":"OWNER","name":"Some User","state":"active","created_at":null,"avatar_url":"https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png","web_url":"https://gitlab.com/OWNER"},"updated_at":"2022-01-20T21:47:31.358Z","created_at":"2022-01-20T21:47:16.276Z","started_at":"2022-01-20T21:47:17.448Z","finished_at":"2022-01-20T21:47:31.35Z","committed_at":null,"duration":14,"queued_duration":1,"coverage":"","web_url":"https://gitlab.com/OWNER/REPO/-/pipelines/452959326","detailed_status":{"icon":"status_success","text":"Passed","label":"passed","group":"success","tooltip":"passed","has_details":true,"details_path":"/OWNER/REPO/-/pipelines/452959326","illustration":{"image":""},"favicon":"/assets/ci_favicons/favicon_status_success-8451333011eee8ce9f2ab25dc487fe24a8758c694827a582f17f42b0a90446a2.png"},"jobs":[{"commit":{"id":"44eb489568f7cb1a5a730fce6b247cd3797172ca","short_id":"44eb4895","title":"Add new file","author_name":"Some User","author_email":"OWNER@gitlab.com","authored_date":"2022-01-20T21:47:15Z","committer_name":"Some User","committer_email":"OWNER@gitlab.com","committed_date":"2022-01-20T21:47:15Z","created_at":"2022-01-20T21:47:15Z","message":"Add new file","parent_ids":["001eb421e586a3f07f90aea102c8b2d4068ab5b6"],"stats":null,"status":null,"last_pipeline":null,"project_id":0,"trailers":{},"web_url":"https://gitlab.com/OWNER/REPO/-/commit/44eb489568f7cb1a5a730fce6b247cd3797172ca"},"coverage":0,"allow_failure":false,"created_at":"2022-01-20T21:47:16.291Z","started_at":"2022-01-20T21:47:16.693Z","finished_at":"2022-01-20T21:47:31.274Z","erased_at":null,"duration":14.580467,"queued_duration":0.211715,"artifacts_expire_at":null,"tag_list":[],"id":1999017704,"name":"test_vars","pipeline":{"id":452959326,"project_id":29316529,"ref":"1-fake-issue-3","sha":"44eb489568f7cb1a5a730fce6b247cd3797172ca","status":"success"},"ref":"1-fake-issue-3","artifacts":[{"file_type":"trace","filename":"job.log","size":2770,"file_format":""}],"artifacts_file":{"filename":"","size":0},"runner":{"id":12270859,"description":"5-green.saas-linux-small-amd64.runners-manager.gitlab.com/default","active":true,"is_shared":true,"name":"gitlab-runner"},"stage":"test","status":"success","failure_reason":"","tag":false,"web_url":"https://gitlab.com/OWNER/REPO/-/jobs/1999017704","project":{"id":0,"description":"","default_branch":"","public":false,"visibility":"","ssh_url_to_repo":"","http_url_to_repo":"","web_url":"","readme_url":"","tag_list":null,"topics":null,"owner":null,"name":"","name_with_namespace":"","path":"","path_with_namespace":"","issues_enabled":false,"open_issues_count":0,"merge_requests_enabled":false,"approvals_before_merge":0,"jobs_enabled":false,"wiki_enabled":false,"snippets_enabled":false,"resolve_outdated_diff_discussions":false,"container_registry_enabled":false,"container_registry_access_level":"","creator_id":0,"namespace":null,"permissions":null,"marked_for_deletion_at":null,"empty_repo":false,"archived":false,"avatar_url":"","license_url":"","license":null,"shared_runners_enabled":false,"group_runners_enabled":false,"runner_token_expiration_interval":0,"forks_count":0,"star_count":0,"runners_token":"","allow_merge_on_skipped_pipeline":false,"only_allow_merge_if_pipeline_succeeds":false,"only_allow_merge_if_all_discussions_are_resolved":false,"remove_source_branch_after_merge":false,"printing_merge_request_link_enabled":false,"lfs_enabled":false,"repository_storage":"","request_access_enabled":false,"merge_method":"","can_create_merge_request_in":false,"forked_from_project":null,"mirror":false,"mirror_user_id":0,"mirror_trigger_builds":false,"only_mirror_protected_branches":false,"mirror_overwrites_diverged_branches":false,"packages_enabled":false,"service_desk_enabled":false,"service_desk_address":"","issues_access_level":"","repository_access_level":"","merge_requests_access_level":"","forking_access_level":"","wiki_access_level":"","builds_access_level":"","snippets_access_level":"","pages_access_level":"","operations_access_level":"","analytics_access_level":"","environments_access_level":"","feature_flags_access_level":"","infrastructure_access_level":"","monitor_access_level":"","autoclose_referenced_issues":false,"suggestion_commit_message":"","squash_option":"","shared_with_groups":null,"statistics":null,"import_url":"","import_type":"","import_status":"","import_error":"","ci_default_git_depth":0,"ci_forward_deployment_enabled":false,"ci_separated_caches":false,"ci_job_token_scope_enabled":false,"ci_opt_in_jwt":false,"ci_allow_fork_pipelines_to_run_in_parent_project":false,"public_jobs":false,"build_timeout":0,"auto_cancel_pending_pipelines":"","ci_config_path":"","custom_attributes":null,"compliance_frameworks":null,"build_coverage_regex":"","issues_template":"","merge_requests_template":"","issue_branch_template":"","keep_latest_artifact":false,"merge_pipelines_enabled":false,"merge_trains_enabled":false,"restrict_user_defined_variables":false,"merge_commit_template":"","squash_commit_template":"","auto_devops_deploy_strategy":"","auto_devops_enabled":false,"build_git_strategy":"","emails_enabled":false,"external_authorization_classification_label":"","requirements_enabled":false,"requirements_access_level":"","security_and_compliance_enabled":false,"security_and_compliance_access_level":"","mr_default_target_self":false,"emails_disabled":false,"public_builds":false},"user":{"id":8814129,"username":"OWNER","email":"","name":"Some User","state":"active","web_url":"https://gitlab.com/OWNER","created_at":"2021-05-03T14:58:50.059Z","bio":"","bot":false,"location":"Canada","public_email":"","skype":"","linkedin":"","twitter":"","website_url":"","organization":"GitLab","job_title":"Sr Backend Engineer","extern_uid":"","provider":"","theme_id":0,"last_activity_on":null,"color_scheme_id":0,"is_admin":false,"avatar_url":"https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png","can_create_group":false,"can_create_project":false,"projects_limit":0,"current_sign_in_at":null,"current_sign_in_ip":null,"last_sign_in_at":null,"last_sign_in_ip":null,"confirmed_at":null,"two_factor_enabled":false,"note":"","identities":null,"external":false,"private_profile":false,"shared_runners_minutes_limit":0,"extra_shared_runners_minutes_limit":0,"using_license_seat":false,"custom_attributes":null,"namespace_id":0}}],"variables":null} -- GitLab From f06b9ce41f7992b9b015e4163eb9f9edbaa1997c Mon Sep 17 00:00:00 2001 From: Dmitry Makovey Date: Wed, 14 Feb 2024 09:48:38 -0800 Subject: [PATCH 07/15] update file names --- commands/ci/get/get_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/commands/ci/get/get_test.go b/commands/ci/get/get_test.go index 41919fac3..370db0b66 100644 --- a/commands/ci/get/get_test.go +++ b/commands/ci/get/get_test.go @@ -403,14 +403,14 @@ No variables found in pipeline. http.MethodGet, "/api/v4/projects/OWNER%2FREPO/pipelines/452959326", http.StatusOK, - "testdata/ci_get-1.json", + "testdata/ci_get-0.json", FILE_BODY, }, { http.MethodGet, "/api/v4/projects/OWNER%2FREPO/pipelines/452959326/jobs?per_page=100", http.StatusOK, - "testdata/ci_get-2.json", + "testdata/ci_get-1.json", FILE_BODY, }, }, -- GitLab From 01f9c5b91032075734be74911d9acc2f3b341ee3 Mon Sep 17 00:00:00 2001 From: Dmitry Makovey Date: Wed, 14 Feb 2024 11:01:49 -0800 Subject: [PATCH 08/15] fix 'ci get' JSON tests --- commands/ci/get/get_test.go | 26 ++++++++++++++++++++------ commands/ci/get/testdata/ci_get-0.json | 13 ++----------- commands/ci/get/testdata/ci_get-1.json | 13 ++----------- 3 files changed, 24 insertions(+), 28 deletions(-) diff --git a/commands/ci/get/get_test.go b/commands/ci/get/get_test.go index 370db0b66..53d24cd89 100644 --- a/commands/ci/get/get_test.go +++ b/commands/ci/get/get_test.go @@ -427,18 +427,32 @@ No variables found in pipeline. defer fakeHTTP.Verify(t) for _, mock := range tc.httpMocks { - fakeHTTP.RegisterResponder(mock.method, mock.path, httpmock.NewStringResponse(mock.status, mock.body)) + var body string + if mock.bodyType == FILE_BODY { + bodyBytes, _ := os.ReadFile(mock.body) + body = string(bodyBytes) + } else { + body = mock.body + } + fakeHTTP.RegisterResponder(mock.method, mock.path, httpmock.NewStringResponse(mock.status, body)) } output, err := runCommand(fakeHTTP, false, tc.args) require.Nil(t, err) + var expectedOut string + var expectedOutBytes []byte fmt.Printf("++>> %s\n", output.String()) - err = os.WriteFile("/tmp/expected", []byte(tc.expectedOut), 0o644) - require.Nil(t, err) - err = os.WriteFile("/tmp/received", []byte(output.String()), 0o644) - require.Nil(t, err) - assert.Equal(t, tc.expectedOut, output.String()) + if tc.expectedOutType == FILE_BODY { + expectedOutBytes, err = os.ReadFile(tc.expectedOut) + expectedOut=string(expectedOutBytes) + require.Nil(t, err) + } else { + expectedOut=tc.expectedOut + } + // err = os.WriteFile("/tmp/received", []byte(output.String()), 0o644) + // require.Nil(t, err) + assert.Equal(t, expectedOut, output.String()) assert.Empty(t, output.Stderr()) }) } diff --git a/commands/ci/get/testdata/ci_get-0.json b/commands/ci/get/testdata/ci_get-0.json index 2a6cd2250..a91de8345 100644 --- a/commands/ci/get/testdata/ci_get-0.json +++ b/commands/ci/get/testdata/ci_get-0.json @@ -1,10 +1,4 @@ -{ - "request": { - "url": "/api/v4/projects/OWNER%2FREPO/pipelines/452959326", - "method": "GET" - }, - "response": { - "body": { + { "id": 452959326, "iid": 14, "project_id": 29316529, @@ -45,7 +39,4 @@ "favicon": "/assets/ci_favicons/favicon_status_success-8451333011eee8ce9f2ab25dc487fe24a8758c694827a582f17f42b0a90446a2.png" }, "name": null - }, - "status": 200 - } -} + } diff --git a/commands/ci/get/testdata/ci_get-1.json b/commands/ci/get/testdata/ci_get-1.json index 44b071531..fbc0ee34b 100644 --- a/commands/ci/get/testdata/ci_get-1.json +++ b/commands/ci/get/testdata/ci_get-1.json @@ -1,10 +1,4 @@ -{ - "request": { - "url": "/api/v4/projects/OWNER%2FREPO/pipelines/452959326/jobs?per_page=100", - "method": "GET" - }, - "response": { - "body": [ + [ { "id": 1999017704, "status": "success", @@ -105,7 +99,4 @@ "archived": false, "tag_list": [] } - ], - "status": 200 - } -} + ] -- GitLab From 69aee96d4f98bff0d93f5a7de1c48e83f18f51b9 Mon Sep 17 00:00:00 2001 From: Dmitry Makovey Date: Wed, 14 Feb 2024 11:06:21 -0800 Subject: [PATCH 09/15] fix lint issues --- commands/ci/get/get_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/commands/ci/get/get_test.go b/commands/ci/get/get_test.go index 53d24cd89..1394a5cd7 100644 --- a/commands/ci/get/get_test.go +++ b/commands/ci/get/get_test.go @@ -445,10 +445,10 @@ No variables found in pipeline. fmt.Printf("++>> %s\n", output.String()) if tc.expectedOutType == FILE_BODY { expectedOutBytes, err = os.ReadFile(tc.expectedOut) - expectedOut=string(expectedOutBytes) + expectedOut = string(expectedOutBytes) require.Nil(t, err) } else { - expectedOut=tc.expectedOut + expectedOut = tc.expectedOut } // err = os.WriteFile("/tmp/received", []byte(output.String()), 0o644) // require.Nil(t, err) -- GitLab From 519dcdbfcb546c657d0832c698309c63ee536b4e Mon Sep 17 00:00:00 2001 From: Dmitry Makovey Date: Wed, 14 Feb 2024 11:30:33 -0800 Subject: [PATCH 10/15] rearrange test files based on experiment with 'ci get' tests --- .../ci/get/testdata/ci_get-0.json | 42 ++++ .../ci/get/testdata/ci_get-0.request | 4 + .../ci/get/testdata/ci_get-1.json | 102 +++++++++ .../ci/get/testdata/ci_get-1.request | 4 + .../ci/get/testdata/ci_get.result | 1 + .../ci/list/testdata/ci_list-0.json | 184 +++++++++++++++++ .../ci/list/testdata/ci_list-0.request | 4 + .../list/testdata/ci_list.result} | 0 test/json_output_data/ci_list.json | 195 ------------------ .../issue/list/testdata/issue_list-0.json | 67 ++++++ .../issue/list/testdata/issue_list-0.request | 4 + .../list/testdata/issue_list.result} | 0 .../issue/view/testdata/issue_view-0.json | 66 ++++++ .../issue/view/testdata/issue_view-0.request | 4 + .../view/testdata/issue_view.result} | 0 test/json_output_data/issue_list.json | 78 ------- test/json_output_data/issue_view.json | 77 ------- .../label/list/testdata/label_list-0.json | 16 ++ .../label/list/testdata/label_list-0.request | 4 + .../list/testdata/label_list.result} | 0 test/json_output_data/label_list.json | 27 --- .../mr/list/testdata/mr_list-0.json | 160 ++++++++++++++ .../mr/list/testdata/mr_list-0.request | 4 + .../list/testdata/mr_list.result} | 0 .../mr/view/testdata/mr_view-0.json | 160 ++++++++++++++ .../mr/view/testdata/mr_view-0.request | 4 + .../mr/view/testdata/mr_view-1.json | 4 + .../mr/view/testdata/mr_view-1.request | 4 + .../view/testdata/mr_view.result} | 0 test/json_output_data/mr_list.json | 171 --------------- test/json_output_data/mr_view.json | 184 ----------------- .../project/list/testdata/project_list-0.json | 195 ++++++++++++++++++ .../list/testdata/project_list-0.request | 4 + .../project/list/testdata/project_list.result | 1 + .../project/view/testdata/project_view-0.json | 177 ++++++++++++++++ .../view/testdata/project_view-0.request | 4 + .../view/testdata/project_view.result} | 0 test/json_output_data/project_list.json | 175 ---------------- .../json_output_data/project_list_result.json | 1 - test/json_output_data/project_view.json | 188 ----------------- .../variable/get/testdata/variable_get-0.json | 10 + .../get/testdata/variable_get-0.request | 4 + .../get/testdata/variable_get.result} | 0 .../list/testdata/variable_list-0.json | 12 ++ .../list/testdata/variable_list-0.request | 4 + .../list/testdata/variable_list.result} | 0 test/json_output_data/variable_get.json | 21 -- test/json_output_data/variable_list.json | 23 --- 48 files changed, 1249 insertions(+), 1140 deletions(-) create mode 100644 test/json_output_data/ci/get/testdata/ci_get-0.json create mode 100644 test/json_output_data/ci/get/testdata/ci_get-0.request create mode 100644 test/json_output_data/ci/get/testdata/ci_get-1.json create mode 100644 test/json_output_data/ci/get/testdata/ci_get-1.request create mode 100644 test/json_output_data/ci/get/testdata/ci_get.result create mode 100644 test/json_output_data/ci/list/testdata/ci_list-0.json create mode 100644 test/json_output_data/ci/list/testdata/ci_list-0.request rename test/json_output_data/{ci_list_result.json => ci/list/testdata/ci_list.result} (100%) delete mode 100644 test/json_output_data/ci_list.json create mode 100644 test/json_output_data/issue/list/testdata/issue_list-0.json create mode 100644 test/json_output_data/issue/list/testdata/issue_list-0.request rename test/json_output_data/{issue_list_result.json => issue/list/testdata/issue_list.result} (100%) create mode 100644 test/json_output_data/issue/view/testdata/issue_view-0.json create mode 100644 test/json_output_data/issue/view/testdata/issue_view-0.request rename test/json_output_data/{issue_view_result.json => issue/view/testdata/issue_view.result} (100%) delete mode 100644 test/json_output_data/issue_list.json delete mode 100644 test/json_output_data/issue_view.json create mode 100644 test/json_output_data/label/list/testdata/label_list-0.json create mode 100644 test/json_output_data/label/list/testdata/label_list-0.request rename test/json_output_data/{label_list_result.json => label/list/testdata/label_list.result} (100%) delete mode 100644 test/json_output_data/label_list.json create mode 100644 test/json_output_data/mr/list/testdata/mr_list-0.json create mode 100644 test/json_output_data/mr/list/testdata/mr_list-0.request rename test/json_output_data/{mr_list_result.json => mr/list/testdata/mr_list.result} (100%) create mode 100644 test/json_output_data/mr/view/testdata/mr_view-0.json create mode 100644 test/json_output_data/mr/view/testdata/mr_view-0.request create mode 100644 test/json_output_data/mr/view/testdata/mr_view-1.json create mode 100644 test/json_output_data/mr/view/testdata/mr_view-1.request rename test/json_output_data/{mr_view_result.json => mr/view/testdata/mr_view.result} (100%) delete mode 100644 test/json_output_data/mr_list.json delete mode 100644 test/json_output_data/mr_view.json create mode 100644 test/json_output_data/project/list/testdata/project_list-0.json create mode 100644 test/json_output_data/project/list/testdata/project_list-0.request create mode 100644 test/json_output_data/project/list/testdata/project_list.result create mode 100644 test/json_output_data/project/view/testdata/project_view-0.json create mode 100644 test/json_output_data/project/view/testdata/project_view-0.request rename test/json_output_data/{project_view_result.json => project/view/testdata/project_view.result} (100%) delete mode 100644 test/json_output_data/project_list.json delete mode 100644 test/json_output_data/project_list_result.json delete mode 100644 test/json_output_data/project_view.json create mode 100644 test/json_output_data/variable/get/testdata/variable_get-0.json create mode 100644 test/json_output_data/variable/get/testdata/variable_get-0.request rename test/json_output_data/{variable_get_result.json => variable/get/testdata/variable_get.result} (100%) create mode 100644 test/json_output_data/variable/list/testdata/variable_list-0.json create mode 100644 test/json_output_data/variable/list/testdata/variable_list-0.request rename test/json_output_data/{variable_list_result.json => variable/list/testdata/variable_list.result} (100%) delete mode 100644 test/json_output_data/variable_get.json delete mode 100644 test/json_output_data/variable_list.json diff --git a/test/json_output_data/ci/get/testdata/ci_get-0.json b/test/json_output_data/ci/get/testdata/ci_get-0.json new file mode 100644 index 000000000..498f83972 --- /dev/null +++ b/test/json_output_data/ci/get/testdata/ci_get-0.json @@ -0,0 +1,42 @@ +{ + "id": 452959326, + "iid": 14, + "project_id": 29316529, + "sha": "44eb489568f7cb1a5a730fce6b247cd3797172ca", + "ref": "1-fake-issue-3", + "status": "success", + "source": "push", + "created_at": "2022-01-20T21:47:16.276Z", + "updated_at": "2022-01-20T21:47:31.358Z", + "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/452959326", + "before_sha": "001eb421e586a3f07f90aea102c8b2d4068ab5b6", + "tag": false, + "yaml_errors": null, + "user": { + "id": 8814129, + "username": "OWNER", + "name": "Some User", + "state": "active", + "locked": false, + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", + "web_url": "https://gitlab.com/OWNER" + }, + "started_at": "2022-01-20T21:47:17.448Z", + "finished_at": "2022-01-20T21:47:31.350Z", + "committed_at": null, + "duration": 14, + "queued_duration": 1, + "coverage": null, + "detailed_status": { + "icon": "status_success", + "text": "Passed", + "label": "passed", + "group": "success", + "tooltip": "passed", + "has_details": true, + "details_path": "/OWNER/REPO/-/pipelines/452959326", + "illustration": null, + "favicon": "/assets/ci_favicons/favicon_status_success-8451333011eee8ce9f2ab25dc487fe24a8758c694827a582f17f42b0a90446a2.png" + }, + "name": null +} diff --git a/test/json_output_data/ci/get/testdata/ci_get-0.request b/test/json_output_data/ci/get/testdata/ci_get-0.request new file mode 100644 index 000000000..0d1edd5a6 --- /dev/null +++ b/test/json_output_data/ci/get/testdata/ci_get-0.request @@ -0,0 +1,4 @@ +{ + "url": "/api/v4/projects/OWNER%2FREPO/pipelines/452959326", + "method": "GET" +} diff --git a/test/json_output_data/ci/get/testdata/ci_get-1.json b/test/json_output_data/ci/get/testdata/ci_get-1.json new file mode 100644 index 000000000..657b6ae95 --- /dev/null +++ b/test/json_output_data/ci/get/testdata/ci_get-1.json @@ -0,0 +1,102 @@ +[ + { + "id": 1999017704, + "status": "success", + "stage": "test", + "name": "test_vars", + "ref": "1-fake-issue-3", + "tag": false, + "coverage": null, + "allow_failure": false, + "created_at": "2022-01-20T21:47:16.291Z", + "started_at": "2022-01-20T21:47:16.693Z", + "finished_at": "2022-01-20T21:47:31.274Z", + "erased_at": null, + "duration": 14.580467, + "queued_duration": 0.211715, + "user": { + "id": 8814129, + "username": "OWNER", + "name": "Some User", + "state": "active", + "locked": false, + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", + "web_url": "https://gitlab.com/OWNER", + "created_at": "2021-05-03T14:58:50.059Z", + "bio": "", + "location": "Canada", + "public_email": "", + "skype": "", + "linkedin": "", + "twitter": "", + "discord": "", + "website_url": "", + "organization": "GitLab", + "job_title": "Sr Backend Engineer", + "pronouns": "", + "bot": false, + "work_information": "Sr Backend Engineer at GitLab", + "followers": 2, + "following": 0, + "local_time": "3:30 PM" + }, + "commit": { + "id": "44eb489568f7cb1a5a730fce6b247cd3797172ca", + "short_id": "44eb4895", + "created_at": "2022-01-20T21:47:15.000+00:00", + "parent_ids": [ + "001eb421e586a3f07f90aea102c8b2d4068ab5b6" + ], + "title": "Add new file", + "message": "Add new file", + "author_name": "Some User", + "author_email": "OWNER@gitlab.com", + "authored_date": "2022-01-20T21:47:15.000+00:00", + "committer_name": "Some User", + "committer_email": "OWNER@gitlab.com", + "committed_date": "2022-01-20T21:47:15.000+00:00", + "trailers": {}, + "extended_trailers": {}, + "web_url": "https://gitlab.com/OWNER/REPO/-/commit/44eb489568f7cb1a5a730fce6b247cd3797172ca" + }, + "pipeline": { + "id": 452959326, + "iid": 14, + "project_id": 29316529, + "sha": "44eb489568f7cb1a5a730fce6b247cd3797172ca", + "ref": "1-fake-issue-3", + "status": "success", + "source": "push", + "created_at": "2022-01-20T21:47:16.276Z", + "updated_at": "2022-01-20T21:47:31.358Z", + "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/452959326" + }, + "web_url": "https://gitlab.com/OWNER/REPO/-/jobs/1999017704", + "project": { + "ci_job_token_scope_enabled": false + }, + "artifacts": [ + { + "file_type": "trace", + "size": 2770, + "filename": "job.log", + "file_format": null + } + ], + "runner": { + "id": 12270859, + "description": "5-green.saas-linux-small-amd64.runners-manager.gitlab.com/default", + "ip_address": "10.1.5.249", + "active": true, + "paused": false, + "is_shared": true, + "runner_type": "instance_type", + "name": "gitlab-runner", + "online": false, + "status": "offline" + }, + "artifacts_expire_at": null, + "archived": false, + "tag_list": [] + } +] diff --git a/test/json_output_data/ci/get/testdata/ci_get-1.request b/test/json_output_data/ci/get/testdata/ci_get-1.request new file mode 100644 index 000000000..d9ad0906a --- /dev/null +++ b/test/json_output_data/ci/get/testdata/ci_get-1.request @@ -0,0 +1,4 @@ +{ + "url": "/api/v4/projects/OWNER%2FREPO/pipelines/452959326/jobs?per_page=100", + "method": "GET" +} diff --git a/test/json_output_data/ci/get/testdata/ci_get.result b/test/json_output_data/ci/get/testdata/ci_get.result new file mode 100644 index 000000000..f997aec80 --- /dev/null +++ b/test/json_output_data/ci/get/testdata/ci_get.result @@ -0,0 +1 @@ +{"id":452959326,"iid":14,"project_id":29316529,"status":"success","source":"push","ref":"1-fake-issue-3","sha":"44eb489568f7cb1a5a730fce6b247cd3797172ca","before_sha":"001eb421e586a3f07f90aea102c8b2d4068ab5b6","tag":false,"yaml_errors":"","user":{"id":8814129,"username":"OWNER","name":"Some User","state":"active","created_at":null,"avatar_url":"https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png","web_url":"https://gitlab.com/OWNER"},"updated_at":"2022-01-20T21:47:31.358Z","created_at":"2022-01-20T21:47:16.276Z","started_at":"2022-01-20T21:47:17.448Z","finished_at":"2022-01-20T21:47:31.35Z","committed_at":null,"duration":14,"queued_duration":1,"coverage":"","web_url":"https://gitlab.com/OWNER/REPO/-/pipelines/452959326","detailed_status":{"icon":"status_success","text":"Passed","label":"passed","group":"success","tooltip":"passed","has_details":true,"details_path":"/OWNER/REPO/-/pipelines/452959326","illustration":{"image":""},"favicon":"/assets/ci_favicons/favicon_status_success-8451333011eee8ce9f2ab25dc487fe24a8758c694827a582f17f42b0a90446a2.png"},"jobs":[{"commit":{"id":"44eb489568f7cb1a5a730fce6b247cd3797172ca","short_id":"44eb4895","title":"Add new file","author_name":"Some User","author_email":"OWNER@gitlab.com","authored_date":"2022-01-20T21:47:15Z","committer_name":"Some User","committer_email":"OWNER@gitlab.com","committed_date":"2022-01-20T21:47:15Z","created_at":"2022-01-20T21:47:15Z","message":"Add new file","parent_ids":["001eb421e586a3f07f90aea102c8b2d4068ab5b6"],"stats":null,"status":null,"last_pipeline":null,"project_id":0,"trailers":{},"web_url":"https://gitlab.com/OWNER/REPO/-/commit/44eb489568f7cb1a5a730fce6b247cd3797172ca"},"coverage":0,"allow_failure":false,"created_at":"2022-01-20T21:47:16.291Z","started_at":"2022-01-20T21:47:16.693Z","finished_at":"2022-01-20T21:47:31.274Z","erased_at":null,"duration":14.580467,"queued_duration":0.211715,"artifacts_expire_at":null,"tag_list":[],"id":1999017704,"name":"test_vars","pipeline":{"id":452959326,"project_id":29316529,"ref":"1-fake-issue-3","sha":"44eb489568f7cb1a5a730fce6b247cd3797172ca","status":"success"},"ref":"1-fake-issue-3","artifacts":[{"file_type":"trace","filename":"job.log","size":2770,"file_format":""}],"artifacts_file":{"filename":"","size":0},"runner":{"id":12270859,"description":"5-green.saas-linux-small-amd64.runners-manager.gitlab.com/default","active":true,"is_shared":true,"name":"gitlab-runner"},"stage":"test","status":"success","failure_reason":"","tag":false,"web_url":"https://gitlab.com/OWNER/REPO/-/jobs/1999017704","project":{"id":0,"description":"","default_branch":"","public":false,"visibility":"","ssh_url_to_repo":"","http_url_to_repo":"","web_url":"","readme_url":"","tag_list":null,"topics":null,"owner":null,"name":"","name_with_namespace":"","path":"","path_with_namespace":"","issues_enabled":false,"open_issues_count":0,"merge_requests_enabled":false,"approvals_before_merge":0,"jobs_enabled":false,"wiki_enabled":false,"snippets_enabled":false,"resolve_outdated_diff_discussions":false,"container_registry_enabled":false,"container_registry_access_level":"","creator_id":0,"namespace":null,"permissions":null,"marked_for_deletion_at":null,"empty_repo":false,"archived":false,"avatar_url":"","license_url":"","license":null,"shared_runners_enabled":false,"group_runners_enabled":false,"runner_token_expiration_interval":0,"forks_count":0,"star_count":0,"runners_token":"","allow_merge_on_skipped_pipeline":false,"only_allow_merge_if_pipeline_succeeds":false,"only_allow_merge_if_all_discussions_are_resolved":false,"remove_source_branch_after_merge":false,"printing_merge_request_link_enabled":false,"lfs_enabled":false,"repository_storage":"","request_access_enabled":false,"merge_method":"","can_create_merge_request_in":false,"forked_from_project":null,"mirror":false,"mirror_user_id":0,"mirror_trigger_builds":false,"only_mirror_protected_branches":false,"mirror_overwrites_diverged_branches":false,"packages_enabled":false,"service_desk_enabled":false,"service_desk_address":"","issues_access_level":"","repository_access_level":"","merge_requests_access_level":"","forking_access_level":"","wiki_access_level":"","builds_access_level":"","snippets_access_level":"","pages_access_level":"","operations_access_level":"","analytics_access_level":"","environments_access_level":"","feature_flags_access_level":"","infrastructure_access_level":"","monitor_access_level":"","autoclose_referenced_issues":false,"suggestion_commit_message":"","squash_option":"","shared_with_groups":null,"statistics":null,"import_url":"","import_type":"","import_status":"","import_error":"","ci_default_git_depth":0,"ci_forward_deployment_enabled":false,"ci_separated_caches":false,"ci_job_token_scope_enabled":false,"ci_opt_in_jwt":false,"ci_allow_fork_pipelines_to_run_in_parent_project":false,"public_jobs":false,"build_timeout":0,"auto_cancel_pending_pipelines":"","ci_config_path":"","custom_attributes":null,"compliance_frameworks":null,"build_coverage_regex":"","issues_template":"","merge_requests_template":"","issue_branch_template":"","keep_latest_artifact":false,"merge_pipelines_enabled":false,"merge_trains_enabled":false,"restrict_user_defined_variables":false,"merge_commit_template":"","squash_commit_template":"","auto_devops_deploy_strategy":"","auto_devops_enabled":false,"build_git_strategy":"","emails_enabled":false,"external_authorization_classification_label":"","requirements_enabled":false,"requirements_access_level":"","security_and_compliance_enabled":false,"security_and_compliance_access_level":"","mr_default_target_self":false,"emails_disabled":false,"public_builds":false},"user":{"id":8814129,"username":"OWNER","email":"","name":"Some User","state":"active","web_url":"https://gitlab.com/OWNER","created_at":"2021-05-03T14:58:50.059Z","bio":"","bot":false,"location":"Canada","public_email":"","skype":"","linkedin":"","twitter":"","website_url":"","organization":"GitLab","job_title":"Sr Backend Engineer","extern_uid":"","provider":"","theme_id":0,"last_activity_on":null,"color_scheme_id":0,"is_admin":false,"avatar_url":"https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png","can_create_group":false,"can_create_project":false,"projects_limit":0,"current_sign_in_at":null,"current_sign_in_ip":null,"last_sign_in_at":null,"last_sign_in_ip":null,"confirmed_at":null,"two_factor_enabled":false,"note":"","identities":null,"external":false,"private_profile":false,"shared_runners_minutes_limit":0,"extra_shared_runners_minutes_limit":0,"using_license_seat":false,"custom_attributes":null,"namespace_id":0}}],"variables":null} diff --git a/test/json_output_data/ci/list/testdata/ci_list-0.json b/test/json_output_data/ci/list/testdata/ci_list-0.json new file mode 100644 index 000000000..abe1eb2e5 --- /dev/null +++ b/test/json_output_data/ci/list/testdata/ci_list-0.json @@ -0,0 +1,184 @@ +[ + { + "id": 452959326, + "iid": 14, + "project_id": 29316529, + "sha": "44eb489568f7cb1a5a730fce6b247cd3797172ca", + "ref": "1-fake-issue-3", + "status": "success", + "source": "push", + "created_at": "2022-01-20T21:47:16.276Z", + "updated_at": "2022-01-20T21:47:31.358Z", + "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/452959326", + "name": null + }, + { + "id": 452944621, + "iid": 13, + "project_id": 29316529, + "sha": "001eb421e586a3f07f90aea102c8b2d4068ab5b6", + "ref": "1-fake-issue-3", + "status": "success", + "source": "push", + "created_at": "2022-01-20T21:20:50.971Z", + "updated_at": "2022-01-20T21:21:04.802Z", + "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/452944621", + "name": null + }, + { + "id": 452941417, + "iid": 12, + "project_id": 29316529, + "sha": "001eb421e586a3f07f90aea102c8b2d4068ab5b6", + "ref": "1-fake-issue", + "status": "success", + "source": "push", + "created_at": "2022-01-20T21:15:42.546Z", + "updated_at": "2022-01-20T21:15:55.200Z", + "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/452941417", + "name": null + }, + { + "id": 452939664, + "iid": 11, + "project_id": 29316529, + "sha": "001eb421e586a3f07f90aea102c8b2d4068ab5b6", + "ref": "1-mr", + "status": "success", + "source": "push", + "created_at": "2022-01-20T21:12:35.048Z", + "updated_at": "2022-01-20T21:12:50.132Z", + "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/452939664", + "name": null + }, + { + "id": 450719821, + "iid": 10, + "project_id": 29316529, + "sha": "123f34ebfd5d97ef562974e55e01b83f06ae7b4a", + "ref": "OWNER-main-patch-25608", + "status": "success", + "source": "push", + "created_at": "2022-01-18T18:06:49.629Z", + "updated_at": "2022-01-18T18:08:09.708Z", + "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/450719821", + "name": null + }, + { + "id": 450714758, + "iid": 9, + "project_id": 29316529, + "sha": "f288fd8d797a05c2946eb5d675f9d4438a150bec", + "ref": "OWNER-main-patch-25608", + "status": "success", + "source": "push", + "created_at": "2022-01-18T18:04:03.546Z", + "updated_at": "2022-01-18T18:05:23.843Z", + "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/450714758", + "name": null + }, + { + "id": 450707660, + "iid": 8, + "project_id": 29316529, + "sha": "afe2714d50f156567ab87c2434cd901de7d341dc", + "ref": "OWNER-main-patch-25608", + "status": "success", + "source": "push", + "created_at": "2022-01-18T18:00:31.663Z", + "updated_at": "2022-01-18T18:01:53.086Z", + "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/450707660", + "name": null + }, + { + "id": 450615878, + "iid": 7, + "project_id": 29316529, + "sha": "a4030d817a2881f5998e6466b9ba90914aecfb18", + "ref": "OWNER-main-patch-25608", + "status": "success", + "source": "push", + "created_at": "2022-01-18T17:02:16.204Z", + "updated_at": "2022-01-18T17:03:22.021Z", + "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/450615878", + "name": null + }, + { + "id": 364128214, + "iid": 6, + "project_id": 29316529, + "sha": "001eb421e586a3f07f90aea102c8b2d4068ab5b6", + "ref": "main", + "status": "success", + "source": "push", + "created_at": "2021-09-02T14:19:52.731Z", + "updated_at": "2021-09-02T14:20:07.800Z", + "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/364128214", + "name": null + }, + { + "id": 364109593, + "iid": 5, + "project_id": 29316529, + "sha": "2a10724040f892e45917e4aef03cdb821e98bd99", + "ref": "main", + "status": "success", + "source": "web", + "created_at": "2021-09-02T13:58:21.181Z", + "updated_at": "2021-09-02T13:58:35.804Z", + "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/364109593", + "name": null + }, + { + "id": 364109341, + "iid": 4, + "project_id": 29316529, + "sha": "2a10724040f892e45917e4aef03cdb821e98bd99", + "ref": "main", + "status": "success", + "source": "push", + "created_at": "2021-09-02T13:57:59.126Z", + "updated_at": "2021-09-02T13:58:11.734Z", + "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/364109341", + "name": null + }, + { + "id": 364104462, + "iid": 3, + "project_id": 29316529, + "sha": "65fb4980734c4b84fa1f7c934c92f747a6fe3ed0", + "ref": "main", + "status": "success", + "source": "web", + "created_at": "2021-09-02T13:51:43.615Z", + "updated_at": "2021-09-02T13:51:57.057Z", + "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/364104462", + "name": null + }, + { + "id": 364102457, + "iid": 2, + "project_id": 29316529, + "sha": "65fb4980734c4b84fa1f7c934c92f747a6fe3ed0", + "ref": "main", + "status": "success", + "source": "push", + "created_at": "2021-09-02T13:48:58.178Z", + "updated_at": "2021-09-02T13:49:10.689Z", + "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/364102457", + "name": null + }, + { + "id": 364098384, + "iid": 1, + "project_id": 29316529, + "sha": "6bd3a42163672bb5341075021d74231c3d75d4b8", + "ref": "main", + "status": "skipped", + "source": "push", + "created_at": "2021-09-02T13:43:57.758Z", + "updated_at": "2021-09-02T13:43:57.758Z", + "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/364098384", + "name": null + } +] diff --git a/test/json_output_data/ci/list/testdata/ci_list-0.request b/test/json_output_data/ci/list/testdata/ci_list-0.request new file mode 100644 index 000000000..33b707893 --- /dev/null +++ b/test/json_output_data/ci/list/testdata/ci_list-0.request @@ -0,0 +1,4 @@ +{ + "url": "/api/v4/projects/OWNER%2FREPO/pipelines?order_by=id&page=1&per_page=30&sort=desc", + "method": "GET" +} diff --git a/test/json_output_data/ci_list_result.json b/test/json_output_data/ci/list/testdata/ci_list.result similarity index 100% rename from test/json_output_data/ci_list_result.json rename to test/json_output_data/ci/list/testdata/ci_list.result diff --git a/test/json_output_data/ci_list.json b/test/json_output_data/ci_list.json deleted file mode 100644 index b768e49f5..000000000 --- a/test/json_output_data/ci_list.json +++ /dev/null @@ -1,195 +0,0 @@ -[ - { - "request": { - "url": "/api/v4/projects/OWNER%2FREPO/pipelines?order_by=id&page=1&per_page=30&sort=desc", - "method": "GET" - }, - "response": { - "body": [ - { - "id": 452959326, - "iid": 14, - "project_id": 29316529, - "sha": "44eb489568f7cb1a5a730fce6b247cd3797172ca", - "ref": "1-fake-issue-3", - "status": "success", - "source": "push", - "created_at": "2022-01-20T21:47:16.276Z", - "updated_at": "2022-01-20T21:47:31.358Z", - "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/452959326", - "name": null - }, - { - "id": 452944621, - "iid": 13, - "project_id": 29316529, - "sha": "001eb421e586a3f07f90aea102c8b2d4068ab5b6", - "ref": "1-fake-issue-3", - "status": "success", - "source": "push", - "created_at": "2022-01-20T21:20:50.971Z", - "updated_at": "2022-01-20T21:21:04.802Z", - "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/452944621", - "name": null - }, - { - "id": 452941417, - "iid": 12, - "project_id": 29316529, - "sha": "001eb421e586a3f07f90aea102c8b2d4068ab5b6", - "ref": "1-fake-issue", - "status": "success", - "source": "push", - "created_at": "2022-01-20T21:15:42.546Z", - "updated_at": "2022-01-20T21:15:55.200Z", - "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/452941417", - "name": null - }, - { - "id": 452939664, - "iid": 11, - "project_id": 29316529, - "sha": "001eb421e586a3f07f90aea102c8b2d4068ab5b6", - "ref": "1-mr", - "status": "success", - "source": "push", - "created_at": "2022-01-20T21:12:35.048Z", - "updated_at": "2022-01-20T21:12:50.132Z", - "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/452939664", - "name": null - }, - { - "id": 450719821, - "iid": 10, - "project_id": 29316529, - "sha": "123f34ebfd5d97ef562974e55e01b83f06ae7b4a", - "ref": "OWNER-main-patch-25608", - "status": "success", - "source": "push", - "created_at": "2022-01-18T18:06:49.629Z", - "updated_at": "2022-01-18T18:08:09.708Z", - "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/450719821", - "name": null - }, - { - "id": 450714758, - "iid": 9, - "project_id": 29316529, - "sha": "f288fd8d797a05c2946eb5d675f9d4438a150bec", - "ref": "OWNER-main-patch-25608", - "status": "success", - "source": "push", - "created_at": "2022-01-18T18:04:03.546Z", - "updated_at": "2022-01-18T18:05:23.843Z", - "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/450714758", - "name": null - }, - { - "id": 450707660, - "iid": 8, - "project_id": 29316529, - "sha": "afe2714d50f156567ab87c2434cd901de7d341dc", - "ref": "OWNER-main-patch-25608", - "status": "success", - "source": "push", - "created_at": "2022-01-18T18:00:31.663Z", - "updated_at": "2022-01-18T18:01:53.086Z", - "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/450707660", - "name": null - }, - { - "id": 450615878, - "iid": 7, - "project_id": 29316529, - "sha": "a4030d817a2881f5998e6466b9ba90914aecfb18", - "ref": "OWNER-main-patch-25608", - "status": "success", - "source": "push", - "created_at": "2022-01-18T17:02:16.204Z", - "updated_at": "2022-01-18T17:03:22.021Z", - "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/450615878", - "name": null - }, - { - "id": 364128214, - "iid": 6, - "project_id": 29316529, - "sha": "001eb421e586a3f07f90aea102c8b2d4068ab5b6", - "ref": "main", - "status": "success", - "source": "push", - "created_at": "2021-09-02T14:19:52.731Z", - "updated_at": "2021-09-02T14:20:07.800Z", - "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/364128214", - "name": null - }, - { - "id": 364109593, - "iid": 5, - "project_id": 29316529, - "sha": "2a10724040f892e45917e4aef03cdb821e98bd99", - "ref": "main", - "status": "success", - "source": "web", - "created_at": "2021-09-02T13:58:21.181Z", - "updated_at": "2021-09-02T13:58:35.804Z", - "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/364109593", - "name": null - }, - { - "id": 364109341, - "iid": 4, - "project_id": 29316529, - "sha": "2a10724040f892e45917e4aef03cdb821e98bd99", - "ref": "main", - "status": "success", - "source": "push", - "created_at": "2021-09-02T13:57:59.126Z", - "updated_at": "2021-09-02T13:58:11.734Z", - "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/364109341", - "name": null - }, - { - "id": 364104462, - "iid": 3, - "project_id": 29316529, - "sha": "65fb4980734c4b84fa1f7c934c92f747a6fe3ed0", - "ref": "main", - "status": "success", - "source": "web", - "created_at": "2021-09-02T13:51:43.615Z", - "updated_at": "2021-09-02T13:51:57.057Z", - "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/364104462", - "name": null - }, - { - "id": 364102457, - "iid": 2, - "project_id": 29316529, - "sha": "65fb4980734c4b84fa1f7c934c92f747a6fe3ed0", - "ref": "main", - "status": "success", - "source": "push", - "created_at": "2021-09-02T13:48:58.178Z", - "updated_at": "2021-09-02T13:49:10.689Z", - "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/364102457", - "name": null - }, - { - "id": 364098384, - "iid": 1, - "project_id": 29316529, - "sha": "6bd3a42163672bb5341075021d74231c3d75d4b8", - "ref": "main", - "status": "skipped", - "source": "push", - "created_at": "2021-09-02T13:43:57.758Z", - "updated_at": "2021-09-02T13:43:57.758Z", - "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/364098384", - "name": null - } - ], - "status": 200 - } - } -] diff --git a/test/json_output_data/issue/list/testdata/issue_list-0.json b/test/json_output_data/issue/list/testdata/issue_list-0.json new file mode 100644 index 000000000..c1067261d --- /dev/null +++ b/test/json_output_data/issue/list/testdata/issue_list-0.json @@ -0,0 +1,67 @@ +[ + { + "id": 101004697, + "iid": 1, + "project_id": 29316529, + "title": "fake issue", + "description": "", + "state": "opened", + "created_at": "2022-01-20T21:11:56.452Z", + "updated_at": "2022-01-20T21:20:51.007Z", + "closed_at": null, + "closed_by": null, + "labels": [], + "milestone": null, + "assignees": [], + "author": { + "id": 8814129, + "username": "OWNER", + "name": "Some User", + "state": "active", + "locked": false, + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", + "web_url": "https://gitlab.com/OWNER" + }, + "type": "ISSUE", + "assignee": null, + "user_notes_count": 0, + "merge_requests_count": 3, + "upvotes": 0, + "downvotes": 0, + "due_date": null, + "confidential": false, + "discussion_locked": null, + "issue_type": "issue", + "web_url": "https://gitlab.com/OWNER/REPO/-/issues/1", + "time_stats": { + "time_estimate": 0, + "total_time_spent": 0, + "human_time_estimate": null, + "human_total_time_spent": null + }, + "task_completion_status": { + "count": 0, + "completed_count": 0 + }, + "weight": null, + "blocking_issues_count": 0, + "has_tasks": true, + "task_status": "", + "_links": { + "self": "https://gitlab.com/api/v4/projects/29316529/issues/1", + "notes": "https://gitlab.com/api/v4/projects/29316529/issues/1/notes", + "award_emoji": "https://gitlab.com/api/v4/projects/29316529/issues/1/award_emoji", + "project": "https://gitlab.com/api/v4/projects/29316529", + "closed_as_duplicate_of": null + }, + "references": { + "short": "#1", + "relative": "#1", + "full": "OWNER/REPO#1" + }, + "severity": "UNKNOWN", + "moved_to_id": null, + "service_desk_reply_to": null, + "health_status": null + } +] diff --git a/test/json_output_data/issue/list/testdata/issue_list-0.request b/test/json_output_data/issue/list/testdata/issue_list-0.request new file mode 100644 index 000000000..c32a9cfdf --- /dev/null +++ b/test/json_output_data/issue/list/testdata/issue_list-0.request @@ -0,0 +1,4 @@ +{ + "url": "/api/v4/projects/OWNER%2FREPO/issues?in=title%2Cdescription&page=1&per_page=30&state=opened", + "method": "GET" +} diff --git a/test/json_output_data/issue_list_result.json b/test/json_output_data/issue/list/testdata/issue_list.result similarity index 100% rename from test/json_output_data/issue_list_result.json rename to test/json_output_data/issue/list/testdata/issue_list.result diff --git a/test/json_output_data/issue/view/testdata/issue_view-0.json b/test/json_output_data/issue/view/testdata/issue_view-0.json new file mode 100644 index 000000000..fe1015a0d --- /dev/null +++ b/test/json_output_data/issue/view/testdata/issue_view-0.json @@ -0,0 +1,66 @@ +{ + "id": 101004697, + "iid": 1, + "project_id": 29316529, + "title": "fake issue", + "description": "", + "state": "opened", + "created_at": "2022-01-20T21:11:56.452Z", + "updated_at": "2022-01-20T21:20:51.007Z", + "closed_at": null, + "closed_by": null, + "labels": [], + "milestone": null, + "assignees": [], + "author": { + "id": 8814129, + "username": "OWNER", + "name": "Some User", + "state": "active", + "locked": false, + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", + "web_url": "https://gitlab.com/OWNER" + }, + "type": "ISSUE", + "assignee": null, + "user_notes_count": 0, + "merge_requests_count": 3, + "upvotes": 0, + "downvotes": 0, + "due_date": null, + "confidential": false, + "discussion_locked": null, + "issue_type": "issue", + "web_url": "https://gitlab.com/OWNER/REPO/-/issues/1", + "time_stats": { + "time_estimate": 0, + "total_time_spent": 0, + "human_time_estimate": null, + "human_total_time_spent": null + }, + "task_completion_status": { + "count": 0, + "completed_count": 0 + }, + "weight": null, + "blocking_issues_count": 0, + "has_tasks": true, + "task_status": "", + "_links": { + "self": "https://gitlab.com/api/v4/projects/29316529/issues/1", + "notes": "https://gitlab.com/api/v4/projects/29316529/issues/1/notes", + "award_emoji": "https://gitlab.com/api/v4/projects/29316529/issues/1/award_emoji", + "project": "https://gitlab.com/api/v4/projects/29316529", + "closed_as_duplicate_of": null + }, + "references": { + "short": "#1", + "relative": "#1", + "full": "OWNER/REPO#1" + }, + "severity": "UNKNOWN", + "subscribed": true, + "moved_to_id": null, + "service_desk_reply_to": null, + "health_status": null +} diff --git a/test/json_output_data/issue/view/testdata/issue_view-0.request b/test/json_output_data/issue/view/testdata/issue_view-0.request new file mode 100644 index 000000000..cf55a48f4 --- /dev/null +++ b/test/json_output_data/issue/view/testdata/issue_view-0.request @@ -0,0 +1,4 @@ +{ + "url": "/api/v4/projects/OWNER%2FREPO/issues/1", + "method": "GET" +} diff --git a/test/json_output_data/issue_view_result.json b/test/json_output_data/issue/view/testdata/issue_view.result similarity index 100% rename from test/json_output_data/issue_view_result.json rename to test/json_output_data/issue/view/testdata/issue_view.result diff --git a/test/json_output_data/issue_list.json b/test/json_output_data/issue_list.json deleted file mode 100644 index 9bd591c50..000000000 --- a/test/json_output_data/issue_list.json +++ /dev/null @@ -1,78 +0,0 @@ -[ - { - "request": { - "url": "/api/v4/projects/OWNER%2FREPO/issues?in=title%2Cdescription&page=1&per_page=30&state=opened", - "method": "GET" - }, - "response": { - "body": [ - { - "id": 101004697, - "iid": 1, - "project_id": 29316529, - "title": "fake issue", - "description": "", - "state": "opened", - "created_at": "2022-01-20T21:11:56.452Z", - "updated_at": "2022-01-20T21:20:51.007Z", - "closed_at": null, - "closed_by": null, - "labels": [], - "milestone": null, - "assignees": [], - "author": { - "id": 8814129, - "username": "OWNER", - "name": "Some User", - "state": "active", - "locked": false, - "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", - "web_url": "https://gitlab.com/OWNER" - }, - "type": "ISSUE", - "assignee": null, - "user_notes_count": 0, - "merge_requests_count": 3, - "upvotes": 0, - "downvotes": 0, - "due_date": null, - "confidential": false, - "discussion_locked": null, - "issue_type": "issue", - "web_url": "https://gitlab.com/OWNER/REPO/-/issues/1", - "time_stats": { - "time_estimate": 0, - "total_time_spent": 0, - "human_time_estimate": null, - "human_total_time_spent": null - }, - "task_completion_status": { - "count": 0, - "completed_count": 0 - }, - "weight": null, - "blocking_issues_count": 0, - "has_tasks": true, - "task_status": "", - "_links": { - "self": "https://gitlab.com/api/v4/projects/29316529/issues/1", - "notes": "https://gitlab.com/api/v4/projects/29316529/issues/1/notes", - "award_emoji": "https://gitlab.com/api/v4/projects/29316529/issues/1/award_emoji", - "project": "https://gitlab.com/api/v4/projects/29316529", - "closed_as_duplicate_of": null - }, - "references": { - "short": "#1", - "relative": "#1", - "full": "OWNER/REPO#1" - }, - "severity": "UNKNOWN", - "moved_to_id": null, - "service_desk_reply_to": null, - "health_status": null - } - ], - "status": 200 - } - } -] diff --git a/test/json_output_data/issue_view.json b/test/json_output_data/issue_view.json deleted file mode 100644 index 54cac4a08..000000000 --- a/test/json_output_data/issue_view.json +++ /dev/null @@ -1,77 +0,0 @@ -[ - { - "request": { - "url": "/api/v4/projects/OWNER%2FREPO/issues/1", - "method": "GET" - }, - "response": { - "body": { - "id": 101004697, - "iid": 1, - "project_id": 29316529, - "title": "fake issue", - "description": "", - "state": "opened", - "created_at": "2022-01-20T21:11:56.452Z", - "updated_at": "2022-01-20T21:20:51.007Z", - "closed_at": null, - "closed_by": null, - "labels": [], - "milestone": null, - "assignees": [], - "author": { - "id": 8814129, - "username": "OWNER", - "name": "Some User", - "state": "active", - "locked": false, - "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", - "web_url": "https://gitlab.com/OWNER" - }, - "type": "ISSUE", - "assignee": null, - "user_notes_count": 0, - "merge_requests_count": 3, - "upvotes": 0, - "downvotes": 0, - "due_date": null, - "confidential": false, - "discussion_locked": null, - "issue_type": "issue", - "web_url": "https://gitlab.com/OWNER/REPO/-/issues/1", - "time_stats": { - "time_estimate": 0, - "total_time_spent": 0, - "human_time_estimate": null, - "human_total_time_spent": null - }, - "task_completion_status": { - "count": 0, - "completed_count": 0 - }, - "weight": null, - "blocking_issues_count": 0, - "has_tasks": true, - "task_status": "", - "_links": { - "self": "https://gitlab.com/api/v4/projects/29316529/issues/1", - "notes": "https://gitlab.com/api/v4/projects/29316529/issues/1/notes", - "award_emoji": "https://gitlab.com/api/v4/projects/29316529/issues/1/award_emoji", - "project": "https://gitlab.com/api/v4/projects/29316529", - "closed_as_duplicate_of": null - }, - "references": { - "short": "#1", - "relative": "#1", - "full": "OWNER/REPO#1" - }, - "severity": "UNKNOWN", - "subscribed": true, - "moved_to_id": null, - "service_desk_reply_to": null, - "health_status": null - }, - "status": 200 - } - } -] diff --git a/test/json_output_data/label/list/testdata/label_list-0.json b/test/json_output_data/label/list/testdata/label_list-0.json new file mode 100644 index 000000000..1bc1dd023 --- /dev/null +++ b/test/json_output_data/label/list/testdata/label_list-0.json @@ -0,0 +1,16 @@ +[ + { + "id": 29739671, + "name": "my label", + "description": "Simple label", + "description_html": "Simple label", + "text_color": "#FFFFFF", + "color": "#00b140", + "open_issues_count": 0, + "closed_issues_count": 0, + "open_merge_requests_count": 0, + "subscribed": false, + "priority": null, + "is_project_label": true + } +] diff --git a/test/json_output_data/label/list/testdata/label_list-0.request b/test/json_output_data/label/list/testdata/label_list-0.request new file mode 100644 index 000000000..a9849b1c9 --- /dev/null +++ b/test/json_output_data/label/list/testdata/label_list-0.request @@ -0,0 +1,4 @@ +{ + "url": "/api/v4/projects/OWNER%2FREPO/labels?page=1&per_page=30&with_counts=true", + "method": "GET" +} diff --git a/test/json_output_data/label_list_result.json b/test/json_output_data/label/list/testdata/label_list.result similarity index 100% rename from test/json_output_data/label_list_result.json rename to test/json_output_data/label/list/testdata/label_list.result diff --git a/test/json_output_data/label_list.json b/test/json_output_data/label_list.json deleted file mode 100644 index 7117daf94..000000000 --- a/test/json_output_data/label_list.json +++ /dev/null @@ -1,27 +0,0 @@ -[ - { - "request": { - "url": "/api/v4/projects/OWNER%2FREPO/labels?page=1&per_page=30&with_counts=true", - "method": "GET" - }, - "response": { - "body": [ - { - "id": 29739671, - "name": "my label", - "description": "Simple label", - "description_html": "Simple label", - "text_color": "#FFFFFF", - "color": "#00b140", - "open_issues_count": 0, - "closed_issues_count": 0, - "open_merge_requests_count": 0, - "subscribed": false, - "priority": null, - "is_project_label": true - } - ], - "status": 200 - } - } -] diff --git a/test/json_output_data/mr/list/testdata/mr_list-0.json b/test/json_output_data/mr/list/testdata/mr_list-0.json new file mode 100644 index 000000000..5ebec2635 --- /dev/null +++ b/test/json_output_data/mr/list/testdata/mr_list-0.json @@ -0,0 +1,160 @@ +[ + { + "id": 136297744, + "iid": 4, + "project_id": 29316529, + "title": "Draft: Resolve \"fake issue\"", + "description": "Closes #1", + "state": "opened", + "created_at": "2022-01-20T21:20:50.665Z", + "updated_at": "2022-01-20T21:47:54.110Z", + "merged_by": null, + "merge_user": null, + "merged_at": null, + "closed_by": null, + "closed_at": null, + "target_branch": "main", + "source_branch": "1-fake-issue-3", + "user_notes_count": 0, + "upvotes": 0, + "downvotes": 0, + "author": { + "id": 8814129, + "username": "OWNER", + "name": "Some User", + "state": "active", + "locked": false, + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", + "web_url": "https://gitlab.com/OWNER" + }, + "assignees": [ + { + "id": 8814129, + "username": "OWNER", + "name": "Some User", + "state": "active", + "locked": false, + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", + "web_url": "https://gitlab.com/OWNER" + } + ], + "assignee": { + "id": 8814129, + "username": "OWNER", + "name": "Some User", + "state": "active", + "locked": false, + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", + "web_url": "https://gitlab.com/OWNER" + }, + "reviewers": [], + "source_project_id": 29316529, + "target_project_id": 29316529, + "labels": [], + "draft": true, + "work_in_progress": true, + "milestone": null, + "merge_when_pipeline_succeeds": false, + "merge_status": "can_be_merged", + "detailed_merge_status": "draft_status", + "sha": "44eb489568f7cb1a5a730fce6b247cd3797172ca", + "merge_commit_sha": null, + "squash_commit_sha": null, + "discussion_locked": null, + "should_remove_source_branch": null, + "force_remove_source_branch": true, + "prepared_at": "2022-01-20T21:20:50.665Z", + "reference": "!4", + "references": { + "short": "!4", + "relative": "!4", + "full": "OWNER/REPO!4" + }, + "web_url": "https://gitlab.com/OWNER/REPO/-/merge_requests/4", + "time_stats": { + "time_estimate": 0, + "total_time_spent": 0, + "human_time_estimate": null, + "human_total_time_spent": null + }, + "squash": false, + "squash_on_merge": false, + "task_completion_status": { + "count": 0, + "completed_count": 0 + }, + "has_conflicts": false, + "blocking_discussions_resolved": true, + "approvals_before_merge": null + }, + { + "id": 135750125, + "iid": 1, + "project_id": 29316529, + "title": "Update .gitlab-ci.yml", + "description": "", + "state": "opened", + "created_at": "2022-01-18T17:02:23.270Z", + "updated_at": "2022-01-18T18:06:50.054Z", + "merged_by": null, + "merge_user": null, + "merged_at": null, + "closed_by": null, + "closed_at": null, + "target_branch": "main", + "source_branch": "OWNER-main-patch-25608", + "user_notes_count": 0, + "upvotes": 0, + "downvotes": 0, + "author": { + "id": 8814129, + "username": "OWNER", + "name": "Some User", + "state": "active", + "locked": false, + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", + "web_url": "https://gitlab.com/OWNER" + }, + "assignees": [], + "assignee": null, + "reviewers": [], + "source_project_id": 29316529, + "target_project_id": 29316529, + "labels": [], + "draft": false, + "work_in_progress": false, + "milestone": null, + "merge_when_pipeline_succeeds": false, + "merge_status": "can_be_merged", + "detailed_merge_status": "mergeable", + "sha": "123f34ebfd5d97ef562974e55e01b83f06ae7b4a", + "merge_commit_sha": null, + "squash_commit_sha": null, + "discussion_locked": null, + "should_remove_source_branch": null, + "force_remove_source_branch": true, + "prepared_at": "2022-01-18T17:02:23.270Z", + "reference": "!1", + "references": { + "short": "!1", + "relative": "!1", + "full": "OWNER/REPO!1" + }, + "web_url": "https://gitlab.com/OWNER/REPO/-/merge_requests/1", + "time_stats": { + "time_estimate": 0, + "total_time_spent": 0, + "human_time_estimate": null, + "human_total_time_spent": null + }, + "squash": false, + "squash_on_merge": false, + "task_completion_status": { + "count": 0, + "completed_count": 0 + }, + "has_conflicts": false, + "blocking_discussions_resolved": true, + "approvals_before_merge": null + } +] diff --git a/test/json_output_data/mr/list/testdata/mr_list-0.request b/test/json_output_data/mr/list/testdata/mr_list-0.request new file mode 100644 index 000000000..b489aa1dc --- /dev/null +++ b/test/json_output_data/mr/list/testdata/mr_list-0.request @@ -0,0 +1,4 @@ +{ + "url": "/api/v4/projects/OWNER%2FREPO/merge_requests?page=1&per_page=30&state=opened", + "method": "GET" +} diff --git a/test/json_output_data/mr_list_result.json b/test/json_output_data/mr/list/testdata/mr_list.result similarity index 100% rename from test/json_output_data/mr_list_result.json rename to test/json_output_data/mr/list/testdata/mr_list.result diff --git a/test/json_output_data/mr/view/testdata/mr_view-0.json b/test/json_output_data/mr/view/testdata/mr_view-0.json new file mode 100644 index 000000000..16ecd35c5 --- /dev/null +++ b/test/json_output_data/mr/view/testdata/mr_view-0.json @@ -0,0 +1,160 @@ +{ + "id": 136297744, + "iid": 4, + "project_id": 29316529, + "title": "Draft: Resolve \"fake issue\"", + "description": "Closes #1", + "state": "opened", + "created_at": "2022-01-20T21:20:50.665Z", + "updated_at": "2022-01-20T21:47:54.110Z", + "merged_by": null, + "merge_user": null, + "merged_at": null, + "closed_by": null, + "closed_at": null, + "title_html": "Draft: Resolve \"fake issue\"", + "description_html": "

Closes #1

", + "target_branch": "main", + "source_branch": "1-fake-issue-3", + "user_notes_count": 0, + "upvotes": 0, + "downvotes": 0, + "author": { + "id": 8814129, + "username": "OWNER", + "name": "Some User", + "state": "active", + "locked": false, + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", + "web_url": "https://gitlab.com/OWNER" + }, + "assignees": [ + { + "id": 8814129, + "username": "OWNER", + "name": "Some User", + "state": "active", + "locked": false, + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", + "web_url": "https://gitlab.com/OWNER" + } + ], + "assignee": { + "id": 8814129, + "username": "OWNER", + "name": "Some User", + "state": "active", + "locked": false, + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", + "web_url": "https://gitlab.com/OWNER" + }, + "reviewers": [], + "source_project_id": 29316529, + "target_project_id": 29316529, + "labels": [], + "draft": true, + "work_in_progress": true, + "milestone": null, + "merge_when_pipeline_succeeds": false, + "merge_status": "can_be_merged", + "detailed_merge_status": "draft_status", + "sha": "44eb489568f7cb1a5a730fce6b247cd3797172ca", + "merge_commit_sha": null, + "squash_commit_sha": null, + "discussion_locked": null, + "should_remove_source_branch": null, + "force_remove_source_branch": true, + "prepared_at": "2022-01-20T21:20:50.665Z", + "reference": "!4", + "references": { + "short": "!4", + "relative": "!4", + "full": "OWNER/REPO!4" + }, + "web_url": "https://gitlab.com/OWNER/REPO/-/merge_requests/4", + "time_stats": { + "time_estimate": 0, + "total_time_spent": 0, + "human_time_estimate": null, + "human_total_time_spent": null + }, + "squash": false, + "squash_on_merge": false, + "task_completion_status": { + "count": 0, + "completed_count": 0 + }, + "has_conflicts": false, + "blocking_discussions_resolved": true, + "approvals_before_merge": null, + "subscribed": true, + "changes_count": "1", + "latest_build_started_at": "2022-01-20T21:47:17.448Z", + "latest_build_finished_at": "2022-01-20T21:47:31.350Z", + "first_deployed_to_production_at": null, + "pipeline": { + "id": 452959326, + "iid": 14, + "project_id": 29316529, + "sha": "44eb489568f7cb1a5a730fce6b247cd3797172ca", + "ref": "1-fake-issue-3", + "status": "success", + "source": "push", + "created_at": "2022-01-20T21:47:16.276Z", + "updated_at": "2022-01-20T21:47:31.358Z", + "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/452959326" + }, + "head_pipeline": { + "id": 452959326, + "iid": 14, + "project_id": 29316529, + "sha": "44eb489568f7cb1a5a730fce6b247cd3797172ca", + "ref": "1-fake-issue-3", + "status": "success", + "source": "push", + "created_at": "2022-01-20T21:47:16.276Z", + "updated_at": "2022-01-20T21:47:31.358Z", + "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/452959326", + "before_sha": "001eb421e586a3f07f90aea102c8b2d4068ab5b6", + "tag": false, + "yaml_errors": null, + "user": { + "id": 8814129, + "username": "OWNER", + "name": "Some User", + "state": "active", + "locked": false, + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", + "web_url": "https://gitlab.com/OWNER" + }, + "started_at": "2022-01-20T21:47:17.448Z", + "finished_at": "2022-01-20T21:47:31.350Z", + "committed_at": null, + "duration": 14, + "queued_duration": 1, + "coverage": null, + "detailed_status": { + "icon": "status_success", + "text": "Passed", + "label": "passed", + "group": "success", + "tooltip": "passed", + "has_details": true, + "details_path": "/OWNER/REPO/-/pipelines/452959326", + "illustration": null, + "favicon": "/assets/ci_favicons/favicon_status_success-8451333011eee8ce9f2ab25dc487fe24a8758c694827a582f17f42b0a90446a2.png" + } + }, + "diff_refs": { + "base_sha": "001eb421e586a3f07f90aea102c8b2d4068ab5b6", + "head_sha": "44eb489568f7cb1a5a730fce6b247cd3797172ca", + "start_sha": "001eb421e586a3f07f90aea102c8b2d4068ab5b6" + }, + "merge_error": null, + "rebase_in_progress": false, + "diverged_commits_count": 0, + "first_contribution": true, + "user": { + "can_merge": true + } +} diff --git a/test/json_output_data/mr/view/testdata/mr_view-0.request b/test/json_output_data/mr/view/testdata/mr_view-0.request new file mode 100644 index 000000000..6ba467a0d --- /dev/null +++ b/test/json_output_data/mr/view/testdata/mr_view-0.request @@ -0,0 +1,4 @@ +{ + "url": "/api/v4/projects/OWNER%2FREPO/merge_requests/4?include_diverged_commits_count=true&include_rebase_in_progress=true&render_html=true", + "method": "GET" +} diff --git a/test/json_output_data/mr/view/testdata/mr_view-1.json b/test/json_output_data/mr/view/testdata/mr_view-1.json new file mode 100644 index 000000000..293243b53 --- /dev/null +++ b/test/json_output_data/mr/view/testdata/mr_view-1.json @@ -0,0 +1,4 @@ +{ + "approval_rules_overwritten": false, + "rules": [] +} diff --git a/test/json_output_data/mr/view/testdata/mr_view-1.request b/test/json_output_data/mr/view/testdata/mr_view-1.request new file mode 100644 index 000000000..92793768a --- /dev/null +++ b/test/json_output_data/mr/view/testdata/mr_view-1.request @@ -0,0 +1,4 @@ +{ + "url": "/api/v4/projects/OWNER%2FREPO/merge_requests/4/approval_state", + "method": "GET" +} diff --git a/test/json_output_data/mr_view_result.json b/test/json_output_data/mr/view/testdata/mr_view.result similarity index 100% rename from test/json_output_data/mr_view_result.json rename to test/json_output_data/mr/view/testdata/mr_view.result diff --git a/test/json_output_data/mr_list.json b/test/json_output_data/mr_list.json deleted file mode 100644 index 15385fa24..000000000 --- a/test/json_output_data/mr_list.json +++ /dev/null @@ -1,171 +0,0 @@ -[ - { - "request": { - "url": "/api/v4/projects/OWNER%2FREPO/merge_requests?page=1&per_page=30&state=opened", - "method": "GET" - }, - "response": { - "body": [ - { - "id": 136297744, - "iid": 4, - "project_id": 29316529, - "title": "Draft: Resolve \"fake issue\"", - "description": "Closes #1", - "state": "opened", - "created_at": "2022-01-20T21:20:50.665Z", - "updated_at": "2022-01-20T21:47:54.110Z", - "merged_by": null, - "merge_user": null, - "merged_at": null, - "closed_by": null, - "closed_at": null, - "target_branch": "main", - "source_branch": "1-fake-issue-3", - "user_notes_count": 0, - "upvotes": 0, - "downvotes": 0, - "author": { - "id": 8814129, - "username": "OWNER", - "name": "Some User", - "state": "active", - "locked": false, - "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", - "web_url": "https://gitlab.com/OWNER" - }, - "assignees": [ - { - "id": 8814129, - "username": "OWNER", - "name": "Some User", - "state": "active", - "locked": false, - "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", - "web_url": "https://gitlab.com/OWNER" - } - ], - "assignee": { - "id": 8814129, - "username": "OWNER", - "name": "Some User", - "state": "active", - "locked": false, - "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", - "web_url": "https://gitlab.com/OWNER" - }, - "reviewers": [], - "source_project_id": 29316529, - "target_project_id": 29316529, - "labels": [], - "draft": true, - "work_in_progress": true, - "milestone": null, - "merge_when_pipeline_succeeds": false, - "merge_status": "can_be_merged", - "detailed_merge_status": "draft_status", - "sha": "44eb489568f7cb1a5a730fce6b247cd3797172ca", - "merge_commit_sha": null, - "squash_commit_sha": null, - "discussion_locked": null, - "should_remove_source_branch": null, - "force_remove_source_branch": true, - "prepared_at": "2022-01-20T21:20:50.665Z", - "reference": "!4", - "references": { - "short": "!4", - "relative": "!4", - "full": "OWNER/REPO!4" - }, - "web_url": "https://gitlab.com/OWNER/REPO/-/merge_requests/4", - "time_stats": { - "time_estimate": 0, - "total_time_spent": 0, - "human_time_estimate": null, - "human_total_time_spent": null - }, - "squash": false, - "squash_on_merge": false, - "task_completion_status": { - "count": 0, - "completed_count": 0 - }, - "has_conflicts": false, - "blocking_discussions_resolved": true, - "approvals_before_merge": null - }, - { - "id": 135750125, - "iid": 1, - "project_id": 29316529, - "title": "Update .gitlab-ci.yml", - "description": "", - "state": "opened", - "created_at": "2022-01-18T17:02:23.270Z", - "updated_at": "2022-01-18T18:06:50.054Z", - "merged_by": null, - "merge_user": null, - "merged_at": null, - "closed_by": null, - "closed_at": null, - "target_branch": "main", - "source_branch": "OWNER-main-patch-25608", - "user_notes_count": 0, - "upvotes": 0, - "downvotes": 0, - "author": { - "id": 8814129, - "username": "OWNER", - "name": "Some User", - "state": "active", - "locked": false, - "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", - "web_url": "https://gitlab.com/OWNER" - }, - "assignees": [], - "assignee": null, - "reviewers": [], - "source_project_id": 29316529, - "target_project_id": 29316529, - "labels": [], - "draft": false, - "work_in_progress": false, - "milestone": null, - "merge_when_pipeline_succeeds": false, - "merge_status": "can_be_merged", - "detailed_merge_status": "mergeable", - "sha": "123f34ebfd5d97ef562974e55e01b83f06ae7b4a", - "merge_commit_sha": null, - "squash_commit_sha": null, - "discussion_locked": null, - "should_remove_source_branch": null, - "force_remove_source_branch": true, - "prepared_at": "2022-01-18T17:02:23.270Z", - "reference": "!1", - "references": { - "short": "!1", - "relative": "!1", - "full": "OWNER/REPO!1" - }, - "web_url": "https://gitlab.com/OWNER/REPO/-/merge_requests/1", - "time_stats": { - "time_estimate": 0, - "total_time_spent": 0, - "human_time_estimate": null, - "human_total_time_spent": null - }, - "squash": false, - "squash_on_merge": false, - "task_completion_status": { - "count": 0, - "completed_count": 0 - }, - "has_conflicts": false, - "blocking_discussions_resolved": true, - "approvals_before_merge": null - } - ], - "status": 200 - } - } -] diff --git a/test/json_output_data/mr_view.json b/test/json_output_data/mr_view.json deleted file mode 100644 index 6fef9b18b..000000000 --- a/test/json_output_data/mr_view.json +++ /dev/null @@ -1,184 +0,0 @@ -[ - { - "request": { - "url": "/api/v4/projects/OWNER%2FREPO/merge_requests/4?include_diverged_commits_count=true&include_rebase_in_progress=true&render_html=true", - "method": "GET" - }, - "response": { - "body": { - "id": 136297744, - "iid": 4, - "project_id": 29316529, - "title": "Draft: Resolve \"fake issue\"", - "description": "Closes #1", - "state": "opened", - "created_at": "2022-01-20T21:20:50.665Z", - "updated_at": "2022-01-20T21:47:54.110Z", - "merged_by": null, - "merge_user": null, - "merged_at": null, - "closed_by": null, - "closed_at": null, - "title_html": "Draft: Resolve \"fake issue\"", - "description_html": "

Closes #1

", - "target_branch": "main", - "source_branch": "1-fake-issue-3", - "user_notes_count": 0, - "upvotes": 0, - "downvotes": 0, - "author": { - "id": 8814129, - "username": "OWNER", - "name": "Some User", - "state": "active", - "locked": false, - "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", - "web_url": "https://gitlab.com/OWNER" - }, - "assignees": [ - { - "id": 8814129, - "username": "OWNER", - "name": "Some User", - "state": "active", - "locked": false, - "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", - "web_url": "https://gitlab.com/OWNER" - } - ], - "assignee": { - "id": 8814129, - "username": "OWNER", - "name": "Some User", - "state": "active", - "locked": false, - "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", - "web_url": "https://gitlab.com/OWNER" - }, - "reviewers": [], - "source_project_id": 29316529, - "target_project_id": 29316529, - "labels": [], - "draft": true, - "work_in_progress": true, - "milestone": null, - "merge_when_pipeline_succeeds": false, - "merge_status": "can_be_merged", - "detailed_merge_status": "draft_status", - "sha": "44eb489568f7cb1a5a730fce6b247cd3797172ca", - "merge_commit_sha": null, - "squash_commit_sha": null, - "discussion_locked": null, - "should_remove_source_branch": null, - "force_remove_source_branch": true, - "prepared_at": "2022-01-20T21:20:50.665Z", - "reference": "!4", - "references": { - "short": "!4", - "relative": "!4", - "full": "OWNER/REPO!4" - }, - "web_url": "https://gitlab.com/OWNER/REPO/-/merge_requests/4", - "time_stats": { - "time_estimate": 0, - "total_time_spent": 0, - "human_time_estimate": null, - "human_total_time_spent": null - }, - "squash": false, - "squash_on_merge": false, - "task_completion_status": { - "count": 0, - "completed_count": 0 - }, - "has_conflicts": false, - "blocking_discussions_resolved": true, - "approvals_before_merge": null, - "subscribed": true, - "changes_count": "1", - "latest_build_started_at": "2022-01-20T21:47:17.448Z", - "latest_build_finished_at": "2022-01-20T21:47:31.350Z", - "first_deployed_to_production_at": null, - "pipeline": { - "id": 452959326, - "iid": 14, - "project_id": 29316529, - "sha": "44eb489568f7cb1a5a730fce6b247cd3797172ca", - "ref": "1-fake-issue-3", - "status": "success", - "source": "push", - "created_at": "2022-01-20T21:47:16.276Z", - "updated_at": "2022-01-20T21:47:31.358Z", - "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/452959326" - }, - "head_pipeline": { - "id": 452959326, - "iid": 14, - "project_id": 29316529, - "sha": "44eb489568f7cb1a5a730fce6b247cd3797172ca", - "ref": "1-fake-issue-3", - "status": "success", - "source": "push", - "created_at": "2022-01-20T21:47:16.276Z", - "updated_at": "2022-01-20T21:47:31.358Z", - "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/452959326", - "before_sha": "001eb421e586a3f07f90aea102c8b2d4068ab5b6", - "tag": false, - "yaml_errors": null, - "user": { - "id": 8814129, - "username": "OWNER", - "name": "Some User", - "state": "active", - "locked": false, - "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", - "web_url": "https://gitlab.com/OWNER" - }, - "started_at": "2022-01-20T21:47:17.448Z", - "finished_at": "2022-01-20T21:47:31.350Z", - "committed_at": null, - "duration": 14, - "queued_duration": 1, - "coverage": null, - "detailed_status": { - "icon": "status_success", - "text": "Passed", - "label": "passed", - "group": "success", - "tooltip": "passed", - "has_details": true, - "details_path": "/OWNER/REPO/-/pipelines/452959326", - "illustration": null, - "favicon": "/assets/ci_favicons/favicon_status_success-8451333011eee8ce9f2ab25dc487fe24a8758c694827a582f17f42b0a90446a2.png" - } - }, - "diff_refs": { - "base_sha": "001eb421e586a3f07f90aea102c8b2d4068ab5b6", - "head_sha": "44eb489568f7cb1a5a730fce6b247cd3797172ca", - "start_sha": "001eb421e586a3f07f90aea102c8b2d4068ab5b6" - }, - "merge_error": null, - "rebase_in_progress": false, - "diverged_commits_count": 0, - "first_contribution": true, - "user": { - "can_merge": true - } - }, - "status": 200 - } - }, - { - "request": { - "url": "/api/v4/projects/OWNER%2FREPO/merge_requests/4/approval_state", - "method": "GET" - }, - "response": { - "body": { - "approval_rules_overwritten": false, - "rules": [] - }, - "status": 200 - } - } -] diff --git a/test/json_output_data/project/list/testdata/project_list-0.json b/test/json_output_data/project/list/testdata/project_list-0.json new file mode 100644 index 000000000..aab22eb36 --- /dev/null +++ b/test/json_output_data/project/list/testdata/project_list-0.json @@ -0,0 +1,195 @@ +[ + { + "id": 36925508, + "description": "A GitLab CLI tool bringing GitLab to your command line", + "name": "cli", + "name_with_namespace": "Some User / cli", + "path": "gitlab-cli", + "path_with_namespace": "OWNER/gitlab-cli", + "created_at": "2022-06-10T15:58:21.579Z", + "default_branch": "main", + "tag_list": [], + "topics": [], + "ssh_url_to_repo": "git@gitlab.com:OWNER/gitlab-cli.git", + "http_url_to_repo": "https://gitlab.com/OWNER/gitlab-cli.git", + "web_url": "https://gitlab.com/OWNER/gitlab-cli", + "readme_url": "https://gitlab.com/OWNER/gitlab-cli/-/blob/main/README.md", + "forks_count": 0, + "avatar_url": "https://gitlab.com/uploads/-/system/project/avatar/36925508/cli-logo.png", + "star_count": 0, + "last_activity_at": "2024-02-13T23:14:22.104Z", + "namespace": { + "id": 11940376, + "name": "Some User", + "path": "OWNER", + "kind": "user", + "full_path": "OWNER", + "parent_id": null, + "avatar_url": "/uploads/-/system/user/avatar/8814129/avatar.png", + "web_url": "https://gitlab.com/OWNER" + }, + "container_registry_image_prefix": "registry.gitlab.com/OWNER/gitlab-cli", + "_links": { + "self": "https://gitlab.com/api/v4/projects/36925508", + "issues": "https://gitlab.com/api/v4/projects/36925508/issues", + "merge_requests": "https://gitlab.com/api/v4/projects/36925508/merge_requests", + "repo_branches": "https://gitlab.com/api/v4/projects/36925508/repository/branches", + "labels": "https://gitlab.com/api/v4/projects/36925508/labels", + "events": "https://gitlab.com/api/v4/projects/36925508/events", + "members": "https://gitlab.com/api/v4/projects/36925508/members", + "cluster_agents": "https://gitlab.com/api/v4/projects/36925508/cluster_agents" + }, + "packages_enabled": true, + "empty_repo": false, + "archived": false, + "visibility": "public", + "owner": { + "id": 8814129, + "username": "OWNER", + "name": "Some User", + "state": "active", + "locked": false, + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", + "web_url": "https://gitlab.com/OWNER" + }, + "resolve_outdated_diff_discussions": false, + "container_expiration_policy": { + "cadence": "1d", + "enabled": false, + "keep_n": 10, + "older_than": "90d", + "name_regex": ".*", + "name_regex_keep": null, + "next_run_at": "2022-06-11T15:58:21.612Z" + }, + "repository_object_format": "sha1", + "issues_enabled": true, + "merge_requests_enabled": true, + "wiki_enabled": true, + "jobs_enabled": true, + "snippets_enabled": true, + "container_registry_enabled": true, + "service_desk_enabled": true, + "service_desk_address": "contact-project+OWNER-gitlab-cli-36925508-issue-@incoming.gitlab.com", + "can_create_merge_request_in": true, + "issues_access_level": "enabled", + "repository_access_level": "enabled", + "merge_requests_access_level": "enabled", + "forking_access_level": "enabled", + "wiki_access_level": "enabled", + "builds_access_level": "enabled", + "snippets_access_level": "enabled", + "pages_access_level": "enabled", + "analytics_access_level": "enabled", + "container_registry_access_level": "enabled", + "security_and_compliance_access_level": "private", + "releases_access_level": "enabled", + "environments_access_level": "enabled", + "feature_flags_access_level": "enabled", + "infrastructure_access_level": "enabled", + "monitor_access_level": "enabled", + "model_experiments_access_level": "enabled", + "model_registry_access_level": "enabled", + "emails_disabled": false, + "emails_enabled": true, + "shared_runners_enabled": true, + "lfs_enabled": true, + "creator_id": 8814129, + "forked_from_project": { + "id": 34675721, + "description": "A GitLab CLI tool bringing GitLab to your command line", + "name": "cli", + "name_with_namespace": "GitLab.org / cli", + "path": "cli", + "path_with_namespace": "gitlab-org/cli", + "created_at": "2022-03-21T18:49:22.691Z", + "default_branch": "main", + "tag_list": [], + "topics": [], + "ssh_url_to_repo": "git@gitlab.com:gitlab-org/cli.git", + "http_url_to_repo": "https://gitlab.com/gitlab-org/cli.git", + "web_url": "https://gitlab.com/gitlab-org/cli", + "readme_url": "https://gitlab.com/gitlab-org/cli/-/blob/main/README.md", + "forks_count": 159, + "avatar_url": "https://gitlab.com/uploads/-/system/project/avatar/34675721/cli-logo.png", + "star_count": 506, + "last_activity_at": "2024-02-13T21:07:22.636Z", + "namespace": { + "id": 9970, + "name": "GitLab.org", + "path": "gitlab-org", + "kind": "group", + "full_path": "gitlab-org", + "parent_id": null, + "avatar_url": "/uploads/-/system/group/avatar/9970/project_avatar.png", + "web_url": "https://gitlab.com/groups/gitlab-org" + } + }, + "mr_default_target_self": false, + "import_url": null, + "import_type": null, + "import_status": "finished", + "open_issues_count": 0, + "description_html": "

A GitLab CLI tool bringing GitLab to your command line

", + "updated_at": "2024-02-13T23:14:22.104Z", + "ci_default_git_depth": 20, + "ci_forward_deployment_enabled": true, + "ci_forward_deployment_rollback_allowed": true, + "ci_job_token_scope_enabled": false, + "ci_separated_caches": true, + "ci_allow_fork_pipelines_to_run_in_parent_project": true, + "build_git_strategy": "fetch", + "keep_latest_artifact": true, + "restrict_user_defined_variables": false, + "runners_token": "GR13489419rM8-WJybx8ggME3Uyf8", + "runner_token_expiration_interval": null, + "group_runners_enabled": true, + "auto_cancel_pending_pipelines": "enabled", + "build_timeout": 3600, + "auto_devops_enabled": false, + "auto_devops_deploy_strategy": "continuous", + "ci_config_path": "", + "public_jobs": true, + "shared_with_groups": [], + "only_allow_merge_if_pipeline_succeeds": false, + "allow_merge_on_skipped_pipeline": null, + "request_access_enabled": true, + "only_allow_merge_if_all_discussions_are_resolved": false, + "remove_source_branch_after_merge": true, + "printing_merge_request_link_enabled": true, + "merge_method": "merge", + "squash_option": "default_off", + "enforce_auth_checks_on_uploads": true, + "suggestion_commit_message": null, + "merge_commit_template": null, + "squash_commit_template": null, + "issue_branch_template": null, + "warn_about_potentially_unwanted_characters": true, + "autoclose_referenced_issues": true, + "approvals_before_merge": 0, + "mirror": false, + "external_authorization_classification_label": "", + "marked_for_deletion_at": null, + "marked_for_deletion_on": null, + "requirements_enabled": true, + "requirements_access_level": "enabled", + "security_and_compliance_enabled": true, + "compliance_frameworks": [], + "issues_template": null, + "merge_requests_template": null, + "ci_restrict_pipeline_cancellation_role": "developer", + "merge_pipelines_enabled": false, + "merge_trains_enabled": false, + "merge_trains_skip_train_allowed": false, + "only_allow_merge_if_all_status_checks_passed": false, + "allow_pipeline_trigger_approve_deployment": false, + "prevent_merge_without_jira_issue": false, + "permissions": { + "project_access": { + "access_level": 50, + "notification_level": 3 + }, + "group_access": null + } + } +] diff --git a/test/json_output_data/project/list/testdata/project_list-0.request b/test/json_output_data/project/list/testdata/project_list-0.request new file mode 100644 index 000000000..8c15d6b79 --- /dev/null +++ b/test/json_output_data/project/list/testdata/project_list-0.request @@ -0,0 +1,4 @@ +{ + "url": "/api/v4/projects?order_by=last_activity_at&owned=true&page=1&per_page=1", + "method": "GET" +} diff --git a/test/json_output_data/project/list/testdata/project_list.result b/test/json_output_data/project/list/testdata/project_list.result new file mode 100644 index 000000000..e44285a8f --- /dev/null +++ b/test/json_output_data/project/list/testdata/project_list.result @@ -0,0 +1 @@ +[{"id":36925508,"description":"A GitLab CLI tool bringing GitLab to your command line","default_branch":"main","public":false,"visibility":"public","ssh_url_to_repo":"git@gitlab.com:OWNER/gitlab-cli.git","http_url_to_repo":"https://gitlab.com/OWNER/gitlab-cli.git","web_url":"https://gitlab.com/OWNER/gitlab-cli","readme_url":"https://gitlab.com/OWNER/gitlab-cli/-/blob/main/README.md","tag_list":[],"topics":[],"owner":{"id":8814129,"username":"OWNER","email":"","name":"Some User","state":"active","web_url":"https://gitlab.com/OWNER","created_at":null,"bio":"","bot":false,"location":"","public_email":"","skype":"","linkedin":"","twitter":"","website_url":"","organization":"","job_title":"","extern_uid":"","provider":"","theme_id":0,"last_activity_on":null,"color_scheme_id":0,"is_admin":false,"avatar_url":"https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png","can_create_group":false,"can_create_project":false,"projects_limit":0,"current_sign_in_at":null,"current_sign_in_ip":null,"last_sign_in_at":null,"last_sign_in_ip":null,"confirmed_at":null,"two_factor_enabled":false,"note":"","identities":null,"external":false,"private_profile":false,"shared_runners_minutes_limit":0,"extra_shared_runners_minutes_limit":0,"using_license_seat":false,"custom_attributes":null,"namespace_id":0},"name":"cli","name_with_namespace":"Some User / cli","path":"gitlab-cli","path_with_namespace":"OWNER/gitlab-cli","issues_enabled":true,"open_issues_count":0,"merge_requests_enabled":true,"approvals_before_merge":0,"jobs_enabled":true,"wiki_enabled":true,"snippets_enabled":true,"resolve_outdated_diff_discussions":false,"container_expiration_policy":{"cadence":"1d","keep_n":10,"older_than":"90d","name_regex":".*","name_regex_delete":"","name_regex_keep":"","enabled":false,"next_run_at":"2022-06-11T15:58:21.612Z"},"container_registry_enabled":true,"container_registry_access_level":"enabled","container_registry_image_prefix":"registry.gitlab.com/OWNER/gitlab-cli","created_at":"2022-06-10T15:58:21.579Z","last_activity_at":"2024-02-13T23:14:22.104Z","creator_id":8814129,"namespace":{"id":11940376,"name":"Some User","path":"OWNER","kind":"user","full_path":"OWNER","parent_id":0,"avatar_url":"/uploads/-/system/user/avatar/8814129/avatar.png","web_url":"https://gitlab.com/OWNER"},"permissions":{"project_access":{"access_level":50,"notification_level":"global"},"group_access":null},"marked_for_deletion_at":null,"empty_repo":false,"archived":false,"avatar_url":"https://gitlab.com/uploads/-/system/project/avatar/36925508/cli-logo.png","license_url":"","license":null,"shared_runners_enabled":true,"group_runners_enabled":true,"runner_token_expiration_interval":0,"forks_count":0,"star_count":0,"runners_token":"GR13489419rM8-WJybx8ggME3Uyf8","allow_merge_on_skipped_pipeline":false,"only_allow_merge_if_pipeline_succeeds":false,"only_allow_merge_if_all_discussions_are_resolved":false,"remove_source_branch_after_merge":true,"printing_merge_request_link_enabled":true,"lfs_enabled":true,"repository_storage":"","request_access_enabled":true,"merge_method":"merge","can_create_merge_request_in":true,"forked_from_project":{"id":34675721,"name":"cli","name_with_namespace":"GitLab.org / cli","path":"cli","path_with_namespace":"gitlab-org/cli","http_url_to_repo":"https://gitlab.com/gitlab-org/cli.git","web_url":"https://gitlab.com/gitlab-org/cli","repository_storage":""},"mirror":false,"mirror_user_id":0,"mirror_trigger_builds":false,"only_mirror_protected_branches":false,"mirror_overwrites_diverged_branches":false,"packages_enabled":true,"service_desk_enabled":true,"service_desk_address":"contact-project+OWNER-gitlab-cli-36925508-issue-@incoming.gitlab.com","issues_access_level":"enabled","releases_access_level":"enabled","repository_access_level":"enabled","merge_requests_access_level":"enabled","forking_access_level":"enabled","wiki_access_level":"enabled","builds_access_level":"enabled","snippets_access_level":"enabled","pages_access_level":"enabled","operations_access_level":"","analytics_access_level":"enabled","environments_access_level":"enabled","feature_flags_access_level":"enabled","infrastructure_access_level":"enabled","monitor_access_level":"enabled","autoclose_referenced_issues":true,"suggestion_commit_message":"","squash_option":"default_off","enforce_auth_checks_on_uploads":true,"shared_with_groups":[],"statistics":null,"_links":{"self":"https://gitlab.com/api/v4/projects/36925508","issues":"https://gitlab.com/api/v4/projects/36925508/issues","merge_requests":"https://gitlab.com/api/v4/projects/36925508/merge_requests","repo_branches":"https://gitlab.com/api/v4/projects/36925508/repository/branches","labels":"https://gitlab.com/api/v4/projects/36925508/labels","events":"https://gitlab.com/api/v4/projects/36925508/events","members":"https://gitlab.com/api/v4/projects/36925508/members","cluster_agents":"https://gitlab.com/api/v4/projects/36925508/cluster_agents"},"import_url":"","import_type":"","import_status":"finished","import_error":"","ci_default_git_depth":20,"ci_forward_deployment_enabled":true,"ci_separated_caches":true,"ci_job_token_scope_enabled":false,"ci_opt_in_jwt":false,"ci_allow_fork_pipelines_to_run_in_parent_project":true,"public_jobs":true,"build_timeout":3600,"auto_cancel_pending_pipelines":"enabled","ci_config_path":"","custom_attributes":null,"compliance_frameworks":[],"build_coverage_regex":"","issues_template":"","merge_requests_template":"","issue_branch_template":"","keep_latest_artifact":true,"merge_pipelines_enabled":false,"merge_trains_enabled":false,"restrict_user_defined_variables":false,"merge_commit_template":"","squash_commit_template":"","auto_devops_deploy_strategy":"continuous","auto_devops_enabled":false,"build_git_strategy":"fetch","emails_enabled":true,"external_authorization_classification_label":"","requirements_enabled":true,"requirements_access_level":"enabled","security_and_compliance_enabled":true,"security_and_compliance_access_level":"private","mr_default_target_self":false,"emails_disabled":false,"public_builds":false}] diff --git a/test/json_output_data/project/view/testdata/project_view-0.json b/test/json_output_data/project/view/testdata/project_view-0.json new file mode 100644 index 000000000..20d0fc8b1 --- /dev/null +++ b/test/json_output_data/project/view/testdata/project_view-0.json @@ -0,0 +1,177 @@ +{ + "id": 29316529, + "description": "", + "name": "REPO", + "name_with_namespace": "Some User / REPO", + "path": "REPO", + "path_with_namespace": "OWNER/REPO", + "created_at": "2021-09-02T13:38:42.806Z", + "default_branch": "main", + "tag_list": [], + "topics": [], + "ssh_url_to_repo": "git@gitlab.com:OWNER/REPO.git", + "http_url_to_repo": "https://gitlab.com/OWNER/REPO.git", + "web_url": "https://gitlab.com/OWNER/REPO", + "readme_url": "https://gitlab.com/OWNER/REPO/-/blob/main/README.md", + "forks_count": 0, + "license_url": null, + "license": null, + "avatar_url": null, + "star_count": 0, + "last_activity_at": "2022-01-20T21:11:56.564Z", + "namespace": { + "id": 11940376, + "name": "Some User", + "path": "OWNER", + "kind": "user", + "full_path": "OWNER", + "parent_id": null, + "avatar_url": "/uploads/-/system/user/avatar/8814129/avatar.png", + "web_url": "https://gitlab.com/OWNER" + }, + "container_registry_image_prefix": "registry.gitlab.com/OWNER/REPO", + "_links": { + "self": "https://gitlab.com/api/v4/projects/29316529", + "issues": "https://gitlab.com/api/v4/projects/29316529/issues", + "merge_requests": "https://gitlab.com/api/v4/projects/29316529/merge_requests", + "repo_branches": "https://gitlab.com/api/v4/projects/29316529/repository/branches", + "labels": "https://gitlab.com/api/v4/projects/29316529/labels", + "events": "https://gitlab.com/api/v4/projects/29316529/events", + "members": "https://gitlab.com/api/v4/projects/29316529/members", + "cluster_agents": "https://gitlab.com/api/v4/projects/29316529/cluster_agents" + }, + "packages_enabled": true, + "empty_repo": false, + "archived": false, + "visibility": "public", + "owner": { + "id": 8814129, + "username": "OWNER", + "name": "Some User", + "state": "active", + "locked": false, + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", + "web_url": "https://gitlab.com/OWNER" + }, + "resolve_outdated_diff_discussions": false, + "container_expiration_policy": { + "cadence": "1d", + "enabled": false, + "keep_n": 10, + "older_than": "90d", + "name_regex": ".*", + "name_regex_keep": null, + "next_run_at": "2021-09-03T13:38:42.834Z" + }, + "repository_object_format": "sha1", + "issues_enabled": true, + "merge_requests_enabled": true, + "wiki_enabled": true, + "jobs_enabled": true, + "snippets_enabled": true, + "container_registry_enabled": true, + "service_desk_enabled": true, + "service_desk_address": "contact-project+OWNER-REPO-29316529-issue-@incoming.gitlab.com", + "can_create_merge_request_in": true, + "issues_access_level": "enabled", + "repository_access_level": "enabled", + "merge_requests_access_level": "enabled", + "forking_access_level": "enabled", + "wiki_access_level": "enabled", + "builds_access_level": "enabled", + "snippets_access_level": "enabled", + "pages_access_level": "enabled", + "analytics_access_level": "enabled", + "container_registry_access_level": "enabled", + "security_and_compliance_access_level": "private", + "releases_access_level": "enabled", + "environments_access_level": "enabled", + "feature_flags_access_level": "enabled", + "infrastructure_access_level": "enabled", + "monitor_access_level": "enabled", + "model_experiments_access_level": "enabled", + "model_registry_access_level": "enabled", + "emails_disabled": false, + "emails_enabled": true, + "shared_runners_enabled": true, + "lfs_enabled": true, + "creator_id": 8814129, + "import_url": null, + "import_type": null, + "import_status": "none", + "import_error": null, + "open_issues_count": 1, + "description_html": "", + "updated_at": "2024-01-19T18:08:30.859Z", + "ci_default_git_depth": 50, + "ci_forward_deployment_enabled": true, + "ci_forward_deployment_rollback_allowed": true, + "ci_job_token_scope_enabled": false, + "ci_separated_caches": true, + "ci_allow_fork_pipelines_to_run_in_parent_project": true, + "build_git_strategy": "fetch", + "keep_latest_artifact": true, + "restrict_user_defined_variables": false, + "runners_token": "GR134894151j85TmuYJpzvNBypfaw", + "runner_token_expiration_interval": null, + "group_runners_enabled": true, + "auto_cancel_pending_pipelines": "enabled", + "build_timeout": 3600, + "auto_devops_enabled": false, + "auto_devops_deploy_strategy": "continuous", + "ci_config_path": "", + "public_jobs": true, + "shared_with_groups": [], + "only_allow_merge_if_pipeline_succeeds": false, + "allow_merge_on_skipped_pipeline": false, + "request_access_enabled": true, + "only_allow_merge_if_all_discussions_are_resolved": false, + "remove_source_branch_after_merge": true, + "printing_merge_request_link_enabled": true, + "merge_method": "merge", + "squash_option": "default_on", + "enforce_auth_checks_on_uploads": true, + "suggestion_commit_message": "", + "merge_commit_template": "", + "squash_commit_template": "", + "issue_branch_template": null, + "statistics": { + "commit_count": 5, + "storage_size": 88110, + "repository_size": 6782, + "wiki_size": 0, + "lfs_objects_size": 0, + "job_artifacts_size": 81328, + "pipeline_artifacts_size": 0, + "packages_size": 0, + "snippets_size": 0, + "uploads_size": 0 + }, + "warn_about_potentially_unwanted_characters": true, + "autoclose_referenced_issues": true, + "approvals_before_merge": 0, + "mirror": false, + "external_authorization_classification_label": "", + "marked_for_deletion_at": null, + "marked_for_deletion_on": null, + "requirements_enabled": true, + "requirements_access_level": "enabled", + "security_and_compliance_enabled": true, + "compliance_frameworks": [], + "issues_template": null, + "merge_requests_template": "", + "ci_restrict_pipeline_cancellation_role": "developer", + "merge_pipelines_enabled": false, + "merge_trains_enabled": false, + "merge_trains_skip_train_allowed": false, + "only_allow_merge_if_all_status_checks_passed": false, + "allow_pipeline_trigger_approve_deployment": false, + "prevent_merge_without_jira_issue": false, + "permissions": { + "project_access": { + "access_level": 50, + "notification_level": 3 + }, + "group_access": null + } +} diff --git a/test/json_output_data/project/view/testdata/project_view-0.request b/test/json_output_data/project/view/testdata/project_view-0.request new file mode 100644 index 000000000..a1a0c54c2 --- /dev/null +++ b/test/json_output_data/project/view/testdata/project_view-0.request @@ -0,0 +1,4 @@ +{ + "url": "/api/v4/projects/OWNER%2FREPO?license=true&statistics=true&with_custom_attributes=true", + "method": "GET" +} diff --git a/test/json_output_data/project_view_result.json b/test/json_output_data/project/view/testdata/project_view.result similarity index 100% rename from test/json_output_data/project_view_result.json rename to test/json_output_data/project/view/testdata/project_view.result diff --git a/test/json_output_data/project_list.json b/test/json_output_data/project_list.json deleted file mode 100644 index 4774dc593..000000000 --- a/test/json_output_data/project_list.json +++ /dev/null @@ -1,175 +0,0 @@ -[ - { - "request": { - "url": "/api/v4/projects?order_by=last_activity_at&owned=true&page=1&per_page=1", - "method": "GET" - }, - "response": { - "body": [ - { - "id": 54865235, - "description": null, - "name": "glab-json", - "name_with_namespace": "Some User / glab-json", - "path": "glab-json", - "path_with_namespace": "OWNER/glab-json", - "created_at": "2024-02-12T19:20:00.943Z", - "default_branch": "main", - "tag_list": [], - "topics": [], - "ssh_url_to_repo": "git@gitlab.com:OWNER/glab-json.git", - "http_url_to_repo": "https://gitlab.com/OWNER/glab-json.git", - "web_url": "https://gitlab.com/OWNER/glab-json", - "readme_url": null, - "forks_count": 0, - "avatar_url": null, - "star_count": 0, - "last_activity_at": "2024-02-12T19:20:00.874Z", - "namespace": { - "id": 11940376, - "name": "Some User", - "path": "OWNER", - "kind": "user", - "full_path": "OWNER", - "parent_id": null, - "avatar_url": "/uploads/-/system/user/avatar/8814129/avatar.png", - "web_url": "https://gitlab.com/OWNER" - }, - "container_registry_image_prefix": "registry.gitlab.com/OWNER/glab-json", - "_links": { - "self": "https://gitlab.com/api/v4/projects/54865235", - "issues": "https://gitlab.com/api/v4/projects/54865235/issues", - "merge_requests": "https://gitlab.com/api/v4/projects/54865235/merge_requests", - "repo_branches": "https://gitlab.com/api/v4/projects/54865235/repository/branches", - "labels": "https://gitlab.com/api/v4/projects/54865235/labels", - "events": "https://gitlab.com/api/v4/projects/54865235/events", - "members": "https://gitlab.com/api/v4/projects/54865235/members", - "cluster_agents": "https://gitlab.com/api/v4/projects/54865235/cluster_agents" - }, - "packages_enabled": true, - "empty_repo": true, - "archived": false, - "visibility": "public", - "owner": { - "id": 8814129, - "username": "OWNER", - "name": "Some User", - "state": "active", - "locked": false, - "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", - "web_url": "https://gitlab.com/OWNER" - }, - "resolve_outdated_diff_discussions": false, - "container_expiration_policy": { - "cadence": "1d", - "enabled": false, - "keep_n": 10, - "older_than": "90d", - "name_regex": ".*", - "name_regex_keep": null, - "next_run_at": "2024-02-13T19:20:00.985Z" - }, - "repository_object_format": "sha1", - "issues_enabled": true, - "merge_requests_enabled": true, - "wiki_enabled": true, - "jobs_enabled": true, - "snippets_enabled": true, - "container_registry_enabled": true, - "service_desk_enabled": true, - "service_desk_address": "contact-project+OWNER-glab-json-54865235-issue-@incoming.gitlab.com", - "can_create_merge_request_in": true, - "issues_access_level": "enabled", - "repository_access_level": "enabled", - "merge_requests_access_level": "enabled", - "forking_access_level": "enabled", - "wiki_access_level": "enabled", - "builds_access_level": "enabled", - "snippets_access_level": "enabled", - "pages_access_level": "enabled", - "analytics_access_level": "enabled", - "container_registry_access_level": "enabled", - "security_and_compliance_access_level": "private", - "releases_access_level": "enabled", - "environments_access_level": "enabled", - "feature_flags_access_level": "enabled", - "infrastructure_access_level": "enabled", - "monitor_access_level": "enabled", - "model_experiments_access_level": "enabled", - "model_registry_access_level": "enabled", - "emails_disabled": false, - "emails_enabled": true, - "shared_runners_enabled": true, - "lfs_enabled": true, - "creator_id": 8814129, - "import_url": null, - "import_type": null, - "import_status": "none", - "open_issues_count": 0, - "description_html": "", - "updated_at": "2024-02-12T19:20:00.943Z", - "ci_default_git_depth": 20, - "ci_forward_deployment_enabled": true, - "ci_forward_deployment_rollback_allowed": true, - "ci_job_token_scope_enabled": false, - "ci_separated_caches": true, - "ci_allow_fork_pipelines_to_run_in_parent_project": true, - "build_git_strategy": "fetch", - "keep_latest_artifact": true, - "restrict_user_defined_variables": false, - "runners_token": "GR1348941D1R_d-qgi-xpbQrpttEg", - "runner_token_expiration_interval": null, - "group_runners_enabled": true, - "auto_cancel_pending_pipelines": "enabled", - "build_timeout": 3600, - "auto_devops_enabled": false, - "auto_devops_deploy_strategy": "continuous", - "ci_config_path": "", - "public_jobs": true, - "shared_with_groups": [], - "only_allow_merge_if_pipeline_succeeds": false, - "allow_merge_on_skipped_pipeline": null, - "request_access_enabled": true, - "only_allow_merge_if_all_discussions_are_resolved": false, - "remove_source_branch_after_merge": true, - "printing_merge_request_link_enabled": true, - "merge_method": "merge", - "squash_option": "default_off", - "enforce_auth_checks_on_uploads": true, - "suggestion_commit_message": null, - "merge_commit_template": null, - "squash_commit_template": null, - "issue_branch_template": null, - "warn_about_potentially_unwanted_characters": true, - "autoclose_referenced_issues": true, - "approvals_before_merge": 0, - "mirror": false, - "external_authorization_classification_label": "", - "marked_for_deletion_at": null, - "marked_for_deletion_on": null, - "requirements_enabled": true, - "requirements_access_level": "enabled", - "security_and_compliance_enabled": true, - "compliance_frameworks": [], - "issues_template": null, - "merge_requests_template": null, - "ci_restrict_pipeline_cancellation_role": "developer", - "merge_pipelines_enabled": false, - "merge_trains_enabled": false, - "merge_trains_skip_train_allowed": false, - "only_allow_merge_if_all_status_checks_passed": false, - "allow_pipeline_trigger_approve_deployment": false, - "prevent_merge_without_jira_issue": false, - "permissions": { - "project_access": { - "access_level": 50, - "notification_level": 3 - }, - "group_access": null - } - } - ], - "status": 200 - } - } -] diff --git a/test/json_output_data/project_list_result.json b/test/json_output_data/project_list_result.json deleted file mode 100644 index fd7c2838f..000000000 --- a/test/json_output_data/project_list_result.json +++ /dev/null @@ -1 +0,0 @@ -[{"id":54865235,"description":"","default_branch":"main","public":false,"visibility":"public","ssh_url_to_repo":"git@gitlab.com:OWNER/glab-json.git","http_url_to_repo":"https://gitlab.com/OWNER/glab-json.git","web_url":"https://gitlab.com/OWNER/glab-json","readme_url":"","tag_list":[],"topics":[],"owner":{"id":8814129,"username":"OWNER","email":"","name":"Some User","state":"active","web_url":"https://gitlab.com/OWNER","created_at":null,"bio":"","bot":false,"location":"","public_email":"","skype":"","linkedin":"","twitter":"","website_url":"","organization":"","job_title":"","extern_uid":"","provider":"","theme_id":0,"last_activity_on":null,"color_scheme_id":0,"is_admin":false,"avatar_url":"https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png","can_create_group":false,"can_create_project":false,"projects_limit":0,"current_sign_in_at":null,"current_sign_in_ip":null,"last_sign_in_at":null,"last_sign_in_ip":null,"confirmed_at":null,"two_factor_enabled":false,"note":"","identities":null,"external":false,"private_profile":false,"shared_runners_minutes_limit":0,"extra_shared_runners_minutes_limit":0,"using_license_seat":false,"custom_attributes":null,"namespace_id":0},"name":"glab-json","name_with_namespace":"Some User / glab-json","path":"glab-json","path_with_namespace":"OWNER/glab-json","issues_enabled":true,"open_issues_count":0,"merge_requests_enabled":true,"approvals_before_merge":0,"jobs_enabled":true,"wiki_enabled":true,"snippets_enabled":true,"resolve_outdated_diff_discussions":false,"container_expiration_policy":{"cadence":"1d","keep_n":10,"older_than":"90d","name_regex":".*","name_regex_delete":"","name_regex_keep":"","enabled":false,"next_run_at":"2024-02-13T19:20:00.985Z"},"container_registry_enabled":true,"container_registry_access_level":"enabled","container_registry_image_prefix":"registry.gitlab.com/OWNER/glab-json","created_at":"2024-02-12T19:20:00.943Z","last_activity_at":"2024-02-12T19:20:00.874Z","creator_id":8814129,"namespace":{"id":11940376,"name":"Some User","path":"OWNER","kind":"user","full_path":"OWNER","parent_id":0,"avatar_url":"/uploads/-/system/user/avatar/8814129/avatar.png","web_url":"https://gitlab.com/OWNER"},"permissions":{"project_access":{"access_level":50,"notification_level":"global"},"group_access":null},"marked_for_deletion_at":null,"empty_repo":true,"archived":false,"avatar_url":"","license_url":"","license":null,"shared_runners_enabled":true,"group_runners_enabled":true,"runner_token_expiration_interval":0,"forks_count":0,"star_count":0,"runners_token":"GR1348941D1R_d-qgi-xpbQrpttEg","allow_merge_on_skipped_pipeline":false,"only_allow_merge_if_pipeline_succeeds":false,"only_allow_merge_if_all_discussions_are_resolved":false,"remove_source_branch_after_merge":true,"printing_merge_request_link_enabled":true,"lfs_enabled":true,"repository_storage":"","request_access_enabled":true,"merge_method":"merge","can_create_merge_request_in":true,"forked_from_project":null,"mirror":false,"mirror_user_id":0,"mirror_trigger_builds":false,"only_mirror_protected_branches":false,"mirror_overwrites_diverged_branches":false,"packages_enabled":true,"service_desk_enabled":true,"service_desk_address":"contact-project+OWNER-glab-json-54865235-issue-@incoming.gitlab.com","issues_access_level":"enabled","releases_access_level":"enabled","repository_access_level":"enabled","merge_requests_access_level":"enabled","forking_access_level":"enabled","wiki_access_level":"enabled","builds_access_level":"enabled","snippets_access_level":"enabled","pages_access_level":"enabled","operations_access_level":"","analytics_access_level":"enabled","environments_access_level":"enabled","feature_flags_access_level":"enabled","infrastructure_access_level":"enabled","monitor_access_level":"enabled","autoclose_referenced_issues":true,"suggestion_commit_message":"","squash_option":"default_off","enforce_auth_checks_on_uploads":true,"shared_with_groups":[],"statistics":null,"_links":{"self":"https://gitlab.com/api/v4/projects/54865235","issues":"https://gitlab.com/api/v4/projects/54865235/issues","merge_requests":"https://gitlab.com/api/v4/projects/54865235/merge_requests","repo_branches":"https://gitlab.com/api/v4/projects/54865235/repository/branches","labels":"https://gitlab.com/api/v4/projects/54865235/labels","events":"https://gitlab.com/api/v4/projects/54865235/events","members":"https://gitlab.com/api/v4/projects/54865235/members","cluster_agents":"https://gitlab.com/api/v4/projects/54865235/cluster_agents"},"import_url":"","import_type":"","import_status":"none","import_error":"","ci_default_git_depth":20,"ci_forward_deployment_enabled":true,"ci_separated_caches":true,"ci_job_token_scope_enabled":false,"ci_opt_in_jwt":false,"ci_allow_fork_pipelines_to_run_in_parent_project":true,"public_jobs":true,"build_timeout":3600,"auto_cancel_pending_pipelines":"enabled","ci_config_path":"","custom_attributes":null,"compliance_frameworks":[],"build_coverage_regex":"","issues_template":"","merge_requests_template":"","issue_branch_template":"","keep_latest_artifact":true,"merge_pipelines_enabled":false,"merge_trains_enabled":false,"restrict_user_defined_variables":false,"merge_commit_template":"","squash_commit_template":"","auto_devops_deploy_strategy":"continuous","auto_devops_enabled":false,"build_git_strategy":"fetch","emails_enabled":true,"external_authorization_classification_label":"","requirements_enabled":true,"requirements_access_level":"enabled","security_and_compliance_enabled":true,"security_and_compliance_access_level":"private","mr_default_target_self":false,"emails_disabled":false,"public_builds":false}] diff --git a/test/json_output_data/project_view.json b/test/json_output_data/project_view.json deleted file mode 100644 index 482d8fffe..000000000 --- a/test/json_output_data/project_view.json +++ /dev/null @@ -1,188 +0,0 @@ -[ - { - "request": { - "url": "/api/v4/projects/OWNER%2FREPO?license=true&statistics=true&with_custom_attributes=true", - "method": "GET" - }, - "response": { - "body": { - "id": 29316529, - "description": "", - "name": "REPO", - "name_with_namespace": "Some User / REPO", - "path": "REPO", - "path_with_namespace": "OWNER/REPO", - "created_at": "2021-09-02T13:38:42.806Z", - "default_branch": "main", - "tag_list": [], - "topics": [], - "ssh_url_to_repo": "git@gitlab.com:OWNER/REPO.git", - "http_url_to_repo": "https://gitlab.com/OWNER/REPO.git", - "web_url": "https://gitlab.com/OWNER/REPO", - "readme_url": "https://gitlab.com/OWNER/REPO/-/blob/main/README.md", - "forks_count": 0, - "license_url": null, - "license": null, - "avatar_url": null, - "star_count": 0, - "last_activity_at": "2022-01-20T21:11:56.564Z", - "namespace": { - "id": 11940376, - "name": "Some User", - "path": "OWNER", - "kind": "user", - "full_path": "OWNER", - "parent_id": null, - "avatar_url": "/uploads/-/system/user/avatar/8814129/avatar.png", - "web_url": "https://gitlab.com/OWNER" - }, - "container_registry_image_prefix": "registry.gitlab.com/OWNER/REPO", - "_links": { - "self": "https://gitlab.com/api/v4/projects/29316529", - "issues": "https://gitlab.com/api/v4/projects/29316529/issues", - "merge_requests": "https://gitlab.com/api/v4/projects/29316529/merge_requests", - "repo_branches": "https://gitlab.com/api/v4/projects/29316529/repository/branches", - "labels": "https://gitlab.com/api/v4/projects/29316529/labels", - "events": "https://gitlab.com/api/v4/projects/29316529/events", - "members": "https://gitlab.com/api/v4/projects/29316529/members", - "cluster_agents": "https://gitlab.com/api/v4/projects/29316529/cluster_agents" - }, - "packages_enabled": true, - "empty_repo": false, - "archived": false, - "visibility": "public", - "owner": { - "id": 8814129, - "username": "OWNER", - "name": "Some User", - "state": "active", - "locked": false, - "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", - "web_url": "https://gitlab.com/OWNER" - }, - "resolve_outdated_diff_discussions": false, - "container_expiration_policy": { - "cadence": "1d", - "enabled": false, - "keep_n": 10, - "older_than": "90d", - "name_regex": ".*", - "name_regex_keep": null, - "next_run_at": "2021-09-03T13:38:42.834Z" - }, - "repository_object_format": "sha1", - "issues_enabled": true, - "merge_requests_enabled": true, - "wiki_enabled": true, - "jobs_enabled": true, - "snippets_enabled": true, - "container_registry_enabled": true, - "service_desk_enabled": true, - "service_desk_address": "contact-project+OWNER-REPO-29316529-issue-@incoming.gitlab.com", - "can_create_merge_request_in": true, - "issues_access_level": "enabled", - "repository_access_level": "enabled", - "merge_requests_access_level": "enabled", - "forking_access_level": "enabled", - "wiki_access_level": "enabled", - "builds_access_level": "enabled", - "snippets_access_level": "enabled", - "pages_access_level": "enabled", - "analytics_access_level": "enabled", - "container_registry_access_level": "enabled", - "security_and_compliance_access_level": "private", - "releases_access_level": "enabled", - "environments_access_level": "enabled", - "feature_flags_access_level": "enabled", - "infrastructure_access_level": "enabled", - "monitor_access_level": "enabled", - "model_experiments_access_level": "enabled", - "model_registry_access_level": "enabled", - "emails_disabled": false, - "emails_enabled": true, - "shared_runners_enabled": true, - "lfs_enabled": true, - "creator_id": 8814129, - "import_url": null, - "import_type": null, - "import_status": "none", - "import_error": null, - "open_issues_count": 1, - "description_html": "", - "updated_at": "2024-01-19T18:08:30.859Z", - "ci_default_git_depth": 50, - "ci_forward_deployment_enabled": true, - "ci_forward_deployment_rollback_allowed": true, - "ci_job_token_scope_enabled": false, - "ci_separated_caches": true, - "ci_allow_fork_pipelines_to_run_in_parent_project": true, - "build_git_strategy": "fetch", - "keep_latest_artifact": true, - "restrict_user_defined_variables": false, - "runners_token": "GR134894151j85TmuYJpzvNBypfaw", - "runner_token_expiration_interval": null, - "group_runners_enabled": true, - "auto_cancel_pending_pipelines": "enabled", - "build_timeout": 3600, - "auto_devops_enabled": false, - "auto_devops_deploy_strategy": "continuous", - "ci_config_path": "", - "public_jobs": true, - "shared_with_groups": [], - "only_allow_merge_if_pipeline_succeeds": false, - "allow_merge_on_skipped_pipeline": false, - "request_access_enabled": true, - "only_allow_merge_if_all_discussions_are_resolved": false, - "remove_source_branch_after_merge": true, - "printing_merge_request_link_enabled": true, - "merge_method": "merge", - "squash_option": "default_on", - "enforce_auth_checks_on_uploads": true, - "suggestion_commit_message": "", - "merge_commit_template": "", - "squash_commit_template": "", - "issue_branch_template": null, - "statistics": { - "commit_count": 5, - "storage_size": 88110, - "repository_size": 6782, - "wiki_size": 0, - "lfs_objects_size": 0, - "job_artifacts_size": 81328, - "pipeline_artifacts_size": 0, - "packages_size": 0, - "snippets_size": 0, - "uploads_size": 0 - }, - "warn_about_potentially_unwanted_characters": true, - "autoclose_referenced_issues": true, - "approvals_before_merge": 0, - "mirror": false, - "external_authorization_classification_label": "", - "marked_for_deletion_at": null, - "marked_for_deletion_on": null, - "requirements_enabled": true, - "requirements_access_level": "enabled", - "security_and_compliance_enabled": true, - "compliance_frameworks": [], - "issues_template": null, - "merge_requests_template": "", - "ci_restrict_pipeline_cancellation_role": "developer", - "merge_pipelines_enabled": false, - "merge_trains_enabled": false, - "merge_trains_skip_train_allowed": false, - "only_allow_merge_if_all_status_checks_passed": false, - "allow_pipeline_trigger_approve_deployment": false, - "prevent_merge_without_jira_issue": false, - "permissions": { - "project_access": { - "access_level": 50, - "notification_level": 3 - }, - "group_access": null - } - }, - "status": 200 - } - } -] diff --git a/test/json_output_data/variable/get/testdata/variable_get-0.json b/test/json_output_data/variable/get/testdata/variable_get-0.json new file mode 100644 index 000000000..5f46d9349 --- /dev/null +++ b/test/json_output_data/variable/get/testdata/variable_get-0.json @@ -0,0 +1,10 @@ +{ + "variable_type": "env_var", + "key": "PROJECT_VAR", + "value": "project", + "protected": false, + "masked": false, + "raw": false, + "environment_scope": "*", + "description": null +} diff --git a/test/json_output_data/variable/get/testdata/variable_get-0.request b/test/json_output_data/variable/get/testdata/variable_get-0.request new file mode 100644 index 000000000..e7d6712d2 --- /dev/null +++ b/test/json_output_data/variable/get/testdata/variable_get-0.request @@ -0,0 +1,4 @@ +{ + "url": "/api/v4/projects/OWNER%2FREPO/variables/PROJECT_VAR?filter%5Benvironment_scope%5D=%2A", + "method": "GET" +} diff --git a/test/json_output_data/variable_get_result.json b/test/json_output_data/variable/get/testdata/variable_get.result similarity index 100% rename from test/json_output_data/variable_get_result.json rename to test/json_output_data/variable/get/testdata/variable_get.result diff --git a/test/json_output_data/variable/list/testdata/variable_list-0.json b/test/json_output_data/variable/list/testdata/variable_list-0.json new file mode 100644 index 000000000..6c3ccb745 --- /dev/null +++ b/test/json_output_data/variable/list/testdata/variable_list-0.json @@ -0,0 +1,12 @@ +[ + { + "variable_type": "env_var", + "key": "PROJECT_VAR", + "value": "project", + "protected": false, + "masked": false, + "raw": false, + "environment_scope": "*", + "description": null + } +] diff --git a/test/json_output_data/variable/list/testdata/variable_list-0.request b/test/json_output_data/variable/list/testdata/variable_list-0.request new file mode 100644 index 000000000..e82d25ca2 --- /dev/null +++ b/test/json_output_data/variable/list/testdata/variable_list-0.request @@ -0,0 +1,4 @@ +{ + "url": "/api/v4/projects/OWNER%2FREPO/variables", + "method": "GET" +} diff --git a/test/json_output_data/variable_list_result.json b/test/json_output_data/variable/list/testdata/variable_list.result similarity index 100% rename from test/json_output_data/variable_list_result.json rename to test/json_output_data/variable/list/testdata/variable_list.result diff --git a/test/json_output_data/variable_get.json b/test/json_output_data/variable_get.json deleted file mode 100644 index a177a2379..000000000 --- a/test/json_output_data/variable_get.json +++ /dev/null @@ -1,21 +0,0 @@ -[ - { - "request": { - "url": "/api/v4/projects/OWNER%2FREPO/variables/PROJECT_VAR?filter%5Benvironment_scope%5D=%2A", - "method": "GET" - }, - "response": { - "body": { - "variable_type": "env_var", - "key": "PROJECT_VAR", - "value": "project", - "protected": false, - "masked": false, - "raw": false, - "environment_scope": "*", - "description": null - }, - "status": 200 - } - } -] diff --git a/test/json_output_data/variable_list.json b/test/json_output_data/variable_list.json deleted file mode 100644 index 02aedd00c..000000000 --- a/test/json_output_data/variable_list.json +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "request": { - "url": "/api/v4/projects/OWNER%2FREPO/variables", - "method": "GET" - }, - "response": { - "body": [ - { - "variable_type": "env_var", - "key": "PROJECT_VAR", - "value": "project", - "protected": false, - "masked": false, - "raw": false, - "environment_scope": "*", - "description": null - } - ], - "status": 200 - } - } -] -- GitLab From febbe897b6fbb8a7592d8e417dfa9ae2c1409e2d Mon Sep 17 00:00:00 2001 From: Dmitry Makovey Date: Fri, 16 Feb 2024 10:54:36 -0800 Subject: [PATCH 11/15] switch to auto-generated code --- commands/ci/get/get_test.go | 8 +- commands/ci/get/testdata/ci_get-0.json | 84 ++++----- commands/ci/get/testdata/ci_get-0.request | 4 - commands/ci/get/testdata/ci_get-1.json | 200 +++++++++++----------- commands/ci/get/testdata/ci_get-1.request | 4 - 5 files changed, 146 insertions(+), 154 deletions(-) delete mode 100644 commands/ci/get/testdata/ci_get-0.request delete mode 100644 commands/ci/get/testdata/ci_get-1.request diff --git a/commands/ci/get/get_test.go b/commands/ci/get/get_test.go index 1394a5cd7..b15ebe70e 100644 --- a/commands/ci/get/get_test.go +++ b/commands/ci/get/get_test.go @@ -396,9 +396,9 @@ No variables found in pipeline. `, }, { - name: "when requesting output as JSON", - args: "-p 452959326 -F json -b main", - httpMocks: []httpMock{ + name: "when getting JSON for pipeline", + args: "-R OWNER/REPO ci get -p 452959326 -F json", + httpmocks: []httpMock{ { http.MethodGet, "/api/v4/projects/OWNER%2FREPO/pipelines/452959326", @@ -414,7 +414,7 @@ No variables found in pipeline. FILE_BODY, }, }, - expectedOut: "testdata/ci_get.result", + expectedOut: "testdata/ci_get.result", expectedOutType: FILE_BODY, }, } diff --git a/commands/ci/get/testdata/ci_get-0.json b/commands/ci/get/testdata/ci_get-0.json index a91de8345..498f83972 100644 --- a/commands/ci/get/testdata/ci_get-0.json +++ b/commands/ci/get/testdata/ci_get-0.json @@ -1,42 +1,42 @@ - { - "id": 452959326, - "iid": 14, - "project_id": 29316529, - "sha": "44eb489568f7cb1a5a730fce6b247cd3797172ca", - "ref": "1-fake-issue-3", - "status": "success", - "source": "push", - "created_at": "2022-01-20T21:47:16.276Z", - "updated_at": "2022-01-20T21:47:31.358Z", - "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/452959326", - "before_sha": "001eb421e586a3f07f90aea102c8b2d4068ab5b6", - "tag": false, - "yaml_errors": null, - "user": { - "id": 8814129, - "username": "OWNER", - "name": "Some User", - "state": "active", - "locked": false, - "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", - "web_url": "https://gitlab.com/OWNER" - }, - "started_at": "2022-01-20T21:47:17.448Z", - "finished_at": "2022-01-20T21:47:31.350Z", - "committed_at": null, - "duration": 14, - "queued_duration": 1, - "coverage": null, - "detailed_status": { - "icon": "status_success", - "text": "Passed", - "label": "passed", - "group": "success", - "tooltip": "passed", - "has_details": true, - "details_path": "/OWNER/REPO/-/pipelines/452959326", - "illustration": null, - "favicon": "/assets/ci_favicons/favicon_status_success-8451333011eee8ce9f2ab25dc487fe24a8758c694827a582f17f42b0a90446a2.png" - }, - "name": null - } +{ + "id": 452959326, + "iid": 14, + "project_id": 29316529, + "sha": "44eb489568f7cb1a5a730fce6b247cd3797172ca", + "ref": "1-fake-issue-3", + "status": "success", + "source": "push", + "created_at": "2022-01-20T21:47:16.276Z", + "updated_at": "2022-01-20T21:47:31.358Z", + "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/452959326", + "before_sha": "001eb421e586a3f07f90aea102c8b2d4068ab5b6", + "tag": false, + "yaml_errors": null, + "user": { + "id": 8814129, + "username": "OWNER", + "name": "Some User", + "state": "active", + "locked": false, + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", + "web_url": "https://gitlab.com/OWNER" + }, + "started_at": "2022-01-20T21:47:17.448Z", + "finished_at": "2022-01-20T21:47:31.350Z", + "committed_at": null, + "duration": 14, + "queued_duration": 1, + "coverage": null, + "detailed_status": { + "icon": "status_success", + "text": "Passed", + "label": "passed", + "group": "success", + "tooltip": "passed", + "has_details": true, + "details_path": "/OWNER/REPO/-/pipelines/452959326", + "illustration": null, + "favicon": "/assets/ci_favicons/favicon_status_success-8451333011eee8ce9f2ab25dc487fe24a8758c694827a582f17f42b0a90446a2.png" + }, + "name": null +} diff --git a/commands/ci/get/testdata/ci_get-0.request b/commands/ci/get/testdata/ci_get-0.request deleted file mode 100644 index 0d1edd5a6..000000000 --- a/commands/ci/get/testdata/ci_get-0.request +++ /dev/null @@ -1,4 +0,0 @@ -{ - "url": "/api/v4/projects/OWNER%2FREPO/pipelines/452959326", - "method": "GET" -} diff --git a/commands/ci/get/testdata/ci_get-1.json b/commands/ci/get/testdata/ci_get-1.json index fbc0ee34b..d43e6eebe 100644 --- a/commands/ci/get/testdata/ci_get-1.json +++ b/commands/ci/get/testdata/ci_get-1.json @@ -1,102 +1,102 @@ - [ +[ + { + "id": 1999017704, + "status": "success", + "stage": "test", + "name": "test_vars", + "ref": "1-fake-issue-3", + "tag": false, + "coverage": null, + "allow_failure": false, + "created_at": "2022-01-20T21:47:16.291Z", + "started_at": "2022-01-20T21:47:16.693Z", + "finished_at": "2022-01-20T21:47:31.274Z", + "erased_at": null, + "duration": 14.580467, + "queued_duration": 0.211715, + "user": { + "id": 8814129, + "username": "OWNER", + "name": "Some User", + "state": "active", + "locked": false, + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", + "web_url": "https://gitlab.com/OWNER", + "created_at": "2021-05-03T14:58:50.059Z", + "bio": "", + "location": "Canada", + "public_email": "", + "skype": "", + "linkedin": "", + "twitter": "", + "discord": "", + "website_url": "", + "organization": "GitLab", + "job_title": "Sr Backend Engineer", + "pronouns": "", + "bot": false, + "work_information": "Sr Backend Engineer at GitLab", + "followers": 2, + "following": 0, + "local_time": "10:48 AM" + }, + "commit": { + "id": "44eb489568f7cb1a5a730fce6b247cd3797172ca", + "short_id": "44eb4895", + "created_at": "2022-01-20T21:47:15.000+00:00", + "parent_ids": [ + "001eb421e586a3f07f90aea102c8b2d4068ab5b6" + ], + "title": "Add new file", + "message": "Add new file", + "author_name": "Some User", + "author_email": "OWNER@gitlab.com", + "authored_date": "2022-01-20T21:47:15.000+00:00", + "committer_name": "Some User", + "committer_email": "OWNER@gitlab.com", + "committed_date": "2022-01-20T21:47:15.000+00:00", + "trailers": {}, + "extended_trailers": {}, + "web_url": "https://gitlab.com/OWNER/REPO/-/commit/44eb489568f7cb1a5a730fce6b247cd3797172ca" + }, + "pipeline": { + "id": 452959326, + "iid": 14, + "project_id": 29316529, + "sha": "44eb489568f7cb1a5a730fce6b247cd3797172ca", + "ref": "1-fake-issue-3", + "status": "success", + "source": "push", + "created_at": "2022-01-20T21:47:16.276Z", + "updated_at": "2022-01-20T21:47:31.358Z", + "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/452959326" + }, + "web_url": "https://gitlab.com/OWNER/REPO/-/jobs/1999017704", + "project": { + "ci_job_token_scope_enabled": false + }, + "artifacts": [ { - "id": 1999017704, - "status": "success", - "stage": "test", - "name": "test_vars", - "ref": "1-fake-issue-3", - "tag": false, - "coverage": null, - "allow_failure": false, - "created_at": "2022-01-20T21:47:16.291Z", - "started_at": "2022-01-20T21:47:16.693Z", - "finished_at": "2022-01-20T21:47:31.274Z", - "erased_at": null, - "duration": 14.580467, - "queued_duration": 0.211715, - "user": { - "id": 8814129, - "username": "OWNER", - "name": "Some User", - "state": "active", - "locked": false, - "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", - "web_url": "https://gitlab.com/OWNER", - "created_at": "2021-05-03T14:58:50.059Z", - "bio": "", - "location": "Canada", - "public_email": "", - "skype": "", - "linkedin": "", - "twitter": "", - "discord": "", - "website_url": "", - "organization": "GitLab", - "job_title": "Sr Backend Engineer", - "pronouns": "", - "bot": false, - "work_information": "Sr Backend Engineer at GitLab", - "followers": 2, - "following": 0, - "local_time": "3:30 PM" - }, - "commit": { - "id": "44eb489568f7cb1a5a730fce6b247cd3797172ca", - "short_id": "44eb4895", - "created_at": "2022-01-20T21:47:15.000+00:00", - "parent_ids": [ - "001eb421e586a3f07f90aea102c8b2d4068ab5b6" - ], - "title": "Add new file", - "message": "Add new file", - "author_name": "Some User", - "author_email": "OWNER@gitlab.com", - "authored_date": "2022-01-20T21:47:15.000+00:00", - "committer_name": "Some User", - "committer_email": "OWNER@gitlab.com", - "committed_date": "2022-01-20T21:47:15.000+00:00", - "trailers": {}, - "extended_trailers": {}, - "web_url": "https://gitlab.com/OWNER/REPO/-/commit/44eb489568f7cb1a5a730fce6b247cd3797172ca" - }, - "pipeline": { - "id": 452959326, - "iid": 14, - "project_id": 29316529, - "sha": "44eb489568f7cb1a5a730fce6b247cd3797172ca", - "ref": "1-fake-issue-3", - "status": "success", - "source": "push", - "created_at": "2022-01-20T21:47:16.276Z", - "updated_at": "2022-01-20T21:47:31.358Z", - "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/452959326" - }, - "web_url": "https://gitlab.com/OWNER/REPO/-/jobs/1999017704", - "project": { - "ci_job_token_scope_enabled": false - }, - "artifacts": [ - { - "file_type": "trace", - "size": 2770, - "filename": "job.log", - "file_format": null - } - ], - "runner": { - "id": 12270859, - "description": "5-green.saas-linux-small-amd64.runners-manager.gitlab.com/default", - "ip_address": "10.1.5.249", - "active": true, - "paused": false, - "is_shared": true, - "runner_type": "instance_type", - "name": "gitlab-runner", - "online": false, - "status": "offline" - }, - "artifacts_expire_at": null, - "archived": false, - "tag_list": [] + "file_type": "trace", + "size": 2770, + "filename": "job.log", + "file_format": null } - ] + ], + "runner": { + "id": 12270859, + "description": "5-green.saas-linux-small-amd64.runners-manager.gitlab.com/default", + "ip_address": "10.1.5.249", + "active": true, + "paused": false, + "is_shared": true, + "runner_type": "instance_type", + "name": "gitlab-runner", + "online": false, + "status": "offline" + }, + "artifacts_expire_at": null, + "archived": false, + "tag_list": [] + } +] diff --git a/commands/ci/get/testdata/ci_get-1.request b/commands/ci/get/testdata/ci_get-1.request deleted file mode 100644 index d9ad0906a..000000000 --- a/commands/ci/get/testdata/ci_get-1.request +++ /dev/null @@ -1,4 +0,0 @@ -{ - "url": "/api/v4/projects/OWNER%2FREPO/pipelines/452959326/jobs?per_page=100", - "method": "GET" -} -- GitLab From 2490b12a30cf47755edf8b23d22aef697be2ce05 Mon Sep 17 00:00:00 2001 From: Dmitry Makovey Date: Fri, 16 Feb 2024 14:08:08 -0800 Subject: [PATCH 12/15] Fixed test --- commands/ci/get/get_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/commands/ci/get/get_test.go b/commands/ci/get/get_test.go index b15ebe70e..42cb21cfe 100644 --- a/commands/ci/get/get_test.go +++ b/commands/ci/get/get_test.go @@ -397,8 +397,8 @@ No variables found in pipeline. }, { name: "when getting JSON for pipeline", - args: "-R OWNER/REPO ci get -p 452959326 -F json", - httpmocks: []httpMock{ + args: "-p 452959326 -F json", + httpMocks: []httpMock{ { http.MethodGet, "/api/v4/projects/OWNER%2FREPO/pipelines/452959326", -- GitLab From 64a94daba724a3aeb31119e9ecca5390dcf49bd8 Mon Sep 17 00:00:00 2001 From: Dmitry Makovey Date: Fri, 16 Feb 2024 14:27:56 -0800 Subject: [PATCH 13/15] gofumping --- commands/ci/get/get_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/commands/ci/get/get_test.go b/commands/ci/get/get_test.go index 42cb21cfe..567b4e7fc 100644 --- a/commands/ci/get/get_test.go +++ b/commands/ci/get/get_test.go @@ -398,7 +398,7 @@ No variables found in pipeline. { name: "when getting JSON for pipeline", args: "-p 452959326 -F json", - httpMocks: []httpMock{ + httpMocks: []httpMock{ { http.MethodGet, "/api/v4/projects/OWNER%2FREPO/pipelines/452959326", @@ -414,7 +414,7 @@ No variables found in pipeline. FILE_BODY, }, }, - expectedOut: "testdata/ci_get.result", + expectedOut: "testdata/ci_get.result", expectedOutType: FILE_BODY, }, } -- GitLab From cc653435344eb278bed2d6d68b4a832887719e14 Mon Sep 17 00:00:00 2001 From: Jay McCure Date: Wed, 21 Feb 2024 17:04:32 +1000 Subject: [PATCH 14/15] test: add json tests --- commands/ci/list/list_test.go | 40 +++- commands/ci/list/testdata/ciList.json | 26 +++ commands/issuable/list/issuable_list_test.go | 28 +++ .../issuable/list/testdata/issueListFull.json | 72 +++++++ commands/issuable/view/issuable_view.go | 1 + commands/issuable/view/issuable_view_test.go | 13 ++ commands/label/list/label_list_test.go | 62 +++++- commands/mr/list/mr_list_test.go | 29 +++ .../mr/list/testdata/mrList.json | 197 +++++++++++------- commands/mr/view/mr_view.go | 1 - commands/mr/view/mr_view_test.go | 15 ++ pkg/httpmock/stub.go | 2 - .../ci/get/testdata/ci_get-0.json | 42 ---- .../ci/get/testdata/ci_get-0.request | 4 - .../ci/get/testdata/ci_get-1.json | 102 --------- .../ci/get/testdata/ci_get-1.request | 4 - .../ci/get/testdata/ci_get.result | 1 - .../ci/list/testdata/ci_list-0.json | 184 ---------------- .../ci/list/testdata/ci_list-0.request | 4 - .../ci/list/testdata/ci_list.result | 1 - .../issue/list/testdata/issue_list-0.json | 67 ------ .../issue/list/testdata/issue_list-0.request | 4 - .../issue/list/testdata/issue_list.result | 1 - .../issue/view/testdata/issue_view-0.json | 66 ------ .../issue/view/testdata/issue_view-0.request | 4 - .../issue/view/testdata/issue_view.result | 1 - .../label/list/testdata/label_list-0.json | 16 -- .../label/list/testdata/label_list-0.request | 4 - .../label/list/testdata/label_list.result | 1 - .../mr/list/testdata/mr_list-0.request | 4 - .../mr/list/testdata/mr_list.result | 1 - .../mr/view/testdata/mr_view-0.json | 160 -------------- .../mr/view/testdata/mr_view-0.request | 4 - .../mr/view/testdata/mr_view-1.json | 4 - .../mr/view/testdata/mr_view-1.request | 4 - .../mr/view/testdata/mr_view.result | 1 - .../project/list/testdata/project_list-0.json | 195 ----------------- .../list/testdata/project_list-0.request | 4 - .../project/list/testdata/project_list.result | 1 - .../project/view/testdata/project_view-0.json | 177 ---------------- .../view/testdata/project_view-0.request | 4 - .../project/view/testdata/project_view.result | 1 - .../variable/get/testdata/variable_get-0.json | 10 - .../get/testdata/variable_get-0.request | 4 - .../variable/get/testdata/variable_get.result | 1 - .../list/testdata/variable_list-0.json | 12 -- .../list/testdata/variable_list-0.request | 4 - .../list/testdata/variable_list.result | 1 - 48 files changed, 390 insertions(+), 1194 deletions(-) create mode 100644 commands/ci/list/testdata/ciList.json create mode 100644 commands/issuable/list/testdata/issueListFull.json rename test/json_output_data/mr/list/testdata/mr_list-0.json => commands/mr/list/testdata/mrList.json (60%) delete mode 100644 test/json_output_data/ci/get/testdata/ci_get-0.json delete mode 100644 test/json_output_data/ci/get/testdata/ci_get-0.request delete mode 100644 test/json_output_data/ci/get/testdata/ci_get-1.json delete mode 100644 test/json_output_data/ci/get/testdata/ci_get-1.request delete mode 100644 test/json_output_data/ci/get/testdata/ci_get.result delete mode 100644 test/json_output_data/ci/list/testdata/ci_list-0.json delete mode 100644 test/json_output_data/ci/list/testdata/ci_list-0.request delete mode 100644 test/json_output_data/ci/list/testdata/ci_list.result delete mode 100644 test/json_output_data/issue/list/testdata/issue_list-0.json delete mode 100644 test/json_output_data/issue/list/testdata/issue_list-0.request delete mode 100644 test/json_output_data/issue/list/testdata/issue_list.result delete mode 100644 test/json_output_data/issue/view/testdata/issue_view-0.json delete mode 100644 test/json_output_data/issue/view/testdata/issue_view-0.request delete mode 100644 test/json_output_data/issue/view/testdata/issue_view.result delete mode 100644 test/json_output_data/label/list/testdata/label_list-0.json delete mode 100644 test/json_output_data/label/list/testdata/label_list-0.request delete mode 100644 test/json_output_data/label/list/testdata/label_list.result delete mode 100644 test/json_output_data/mr/list/testdata/mr_list-0.request delete mode 100644 test/json_output_data/mr/list/testdata/mr_list.result delete mode 100644 test/json_output_data/mr/view/testdata/mr_view-0.json delete mode 100644 test/json_output_data/mr/view/testdata/mr_view-0.request delete mode 100644 test/json_output_data/mr/view/testdata/mr_view-1.json delete mode 100644 test/json_output_data/mr/view/testdata/mr_view-1.request delete mode 100644 test/json_output_data/mr/view/testdata/mr_view.result delete mode 100644 test/json_output_data/project/list/testdata/project_list-0.json delete mode 100644 test/json_output_data/project/list/testdata/project_list-0.request delete mode 100644 test/json_output_data/project/list/testdata/project_list.result delete mode 100644 test/json_output_data/project/view/testdata/project_view-0.json delete mode 100644 test/json_output_data/project/view/testdata/project_view-0.request delete mode 100644 test/json_output_data/project/view/testdata/project_view.result delete mode 100644 test/json_output_data/variable/get/testdata/variable_get-0.json delete mode 100644 test/json_output_data/variable/get/testdata/variable_get-0.request delete mode 100644 test/json_output_data/variable/get/testdata/variable_get.result delete mode 100644 test/json_output_data/variable/list/testdata/variable_list-0.json delete mode 100644 test/json_output_data/variable/list/testdata/variable_list-0.request delete mode 100644 test/json_output_data/variable/list/testdata/variable_list.result diff --git a/commands/ci/list/list_test.go b/commands/ci/list/list_test.go index 841c736af..c88870d23 100644 --- a/commands/ci/list/list_test.go +++ b/commands/ci/list/list_test.go @@ -1,12 +1,12 @@ package list import ( + "fmt" "net/http" + "os" "regexp" "testing" - "gitlab.com/gitlab-org/cli/pkg/iostreams" - "github.com/MakeNowJust/heredoc" "github.com/stretchr/testify/assert" @@ -15,19 +15,16 @@ import ( "gitlab.com/gitlab-org/cli/test" ) -func runCommand(rt http.RoundTripper) (*test.CmdOut, error) { - ios, _, stdout, stderr := iostreams.Test() +func runCommand(rt http.RoundTripper, args string) (*test.CmdOut, error) { + ios, _, stdout, stderr := cmdtest.InitIOStreams(false, "") + factory := cmdtest.InitFactory(ios, rt) _, _ = factory.HttpClient() cmd := NewCmdList(factory) - _, err := cmd.ExecuteC() - return &test.CmdOut{ - OutBuf: stdout, - ErrBuf: stderr, - }, err + return cmdtest.ExecuteCommand(cmd, args, stdout, stderr) } func TestCiList(t *testing.T) { @@ -64,7 +61,7 @@ func TestCiList(t *testing.T) { ] `)) - output, err := runCommand(fakeHTTP) + output, err := runCommand(fakeHTTP, "") if err != nil { t.Errorf("error running command `ci list`: %v", err) } @@ -82,3 +79,26 @@ func TestCiList(t *testing.T) { `), out) assert.Empty(t, output.Stderr()) } + +func TestCiListJSON(t *testing.T) { + fakeHTTP := httpmock.New() + defer fakeHTTP.Verify(t) + + fakeHTTP.RegisterResponder(http.MethodGet, "/api/v4/projects/OWNER/REPO/pipelines", + httpmock.NewFileResponse(http.StatusOK, "testdata/ciList.json")) + + output, err := runCommand(fakeHTTP, "-F json") + if err != nil { + t.Errorf("error running command `ci list -F json`: %v", err) + } + + b, err := os.ReadFile("testdata/ciList.json") + if err != nil { + fmt.Print(err) + } + + expectedOut := string(b) + + assert.JSONEq(t, expectedOut, output.String()) + assert.Empty(t, output.Stderr()) +} diff --git a/commands/ci/list/testdata/ciList.json b/commands/ci/list/testdata/ciList.json new file mode 100644 index 000000000..929736526 --- /dev/null +++ b/commands/ci/list/testdata/ciList.json @@ -0,0 +1,26 @@ +[ + { + "id": 1172622998, + "iid": 338, + "project_id": 37777023, + "status": "success", + "source": "schedule", + "ref": "#test#", + "sha": "3c890c11d784329052aa4ff63526dde2fa65b320", + "web_url": "https://gitlab.com/jay_mccure/test2target/-/pipelines/1172622998", + "updated_at": "2024-02-11T18:56:07.777Z", + "created_at": "2024-02-11T18:55:08.793Z" + }, + { + "id": 1172086480, + "iid": 337, + "project_id": 37777023, + "status": "success", + "source": "schedule", + "ref": "#test#", + "sha": "3c890c11d784329052aa4ff63526dde2fa65b320", + "web_url": "https://gitlab.com/jay_mccure/test2target/-/pipelines/1172086480", + "updated_at": "2024-02-10T18:56:13.972Z", + "created_at": "2024-02-10T18:55:16.722Z" + } +] \ No newline at end of file diff --git a/commands/issuable/list/issuable_list_test.go b/commands/issuable/list/issuable_list_test.go index 6d23b0427..125855ec1 100644 --- a/commands/issuable/list/issuable_list_test.go +++ b/commands/issuable/list/issuable_list_test.go @@ -3,6 +3,7 @@ package list import ( "fmt" "net/http" + "os" "regexp" "strings" "testing" @@ -350,3 +351,30 @@ func TestIssueList_hyperlinks(t *testing.T) { }) } } + +func TestIssueListJSON(t *testing.T) { + fakeHTTP := httpmock.New() + defer fakeHTTP.Verify(t) + + fakeHTTP.RegisterResponder(http.MethodGet, "/projects/OWNER/REPO/issues", + httpmock.NewFileResponse(http.StatusOK, "./testdata/issueListFull.json")) + + output, err := runCommand("issue", fakeHTTP, true, "-F json", nil, "") + if err != nil { + t.Errorf("error running command `issue list -F json`: %v", err) + } + + if err != nil { + panic(err) + } + + b, err := os.ReadFile("./testdata/issueListFull.json") + if err != nil { + fmt.Print(err) + } + + expectedOut := string(b) + + assert.JSONEq(t, expectedOut, output.String()) + assert.Empty(t, output.Stderr()) +} diff --git a/commands/issuable/list/testdata/issueListFull.json b/commands/issuable/list/testdata/issueListFull.json new file mode 100644 index 000000000..ec63ebd98 --- /dev/null +++ b/commands/issuable/list/testdata/issueListFull.json @@ -0,0 +1,72 @@ +[ + { + "id": 141525495, + "iid": 15, + "external_id": "", + "project_id": 37777023, + "title": "tem", + "description": "", + "state": "opened", + "created_at": "2024-01-31T05:37:57.883Z", + "updated_at": "2024-02-02T00:54:02.842Z", + "closed_at": null, + "epic": null, + "epic_issue_id": 0, + "iteration": null, + "label_details": null, + "subscribed": false, + "closed_by": null, + "labels":"", + "milestone": null, + "assignees": + [], + "author": + { + "id": 11809982, + "username": "jay_mccure", + "name": "Jay McCure", + "state": "active", + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/11809982/avatar.png", + "web_url": "https://gitlab.com/jay_mccure" + }, + "assignee": null, + "user_notes_count": 0, + "issue_link_id": 0, + "merge_requests_count": 0, + "upvotes": 0, + "downvotes": 0, + "due_date": null, + "confidential": false, + "discussion_locked": false, + "issue_type": "issue", + "web_url": "https://gitlab.com/jay_mccure/test2target/-/issues/15", + "time_stats": + { + "time_estimate": 0, + "total_time_spent": 0, + "human_time_estimate": "", + "human_total_time_spent": "" + }, + "task_completion_status": + { + "count": 0, + "completed_count": 0 + }, + "weight": 0, + "_links": + { + "self": "https://gitlab.com/api/v4/projects/37777023/issues/15", + "notes": "https://gitlab.com/api/v4/projects/37777023/issues/15/notes", + "award_emoji": "https://gitlab.com/api/v4/projects/37777023/issues/15/award_emoji", + "project": "https://gitlab.com/api/v4/projects/37777023" + }, + "references": + { + "short": "#15", + "relative": "#15", + "full": "jay_mccure/test2target#15" + }, + "moved_to_id": 0, + "health_status": "" + } +] \ No newline at end of file diff --git a/commands/issuable/view/issuable_view.go b/commands/issuable/view/issuable_view.go index ecb18ef87..99b2bb306 100644 --- a/commands/issuable/view/issuable_view.go +++ b/commands/issuable/view/issuable_view.go @@ -290,6 +290,7 @@ func RawIssuableNotes(notes []*gitlab.Note, showComments bool, showSystemLogs bo func printJSONIssue(opts *ViewOpts) error { // var notes []gitlab.Note if opts.ShowComments { + extendedIssue := IssueWithNotes{opts.Issue, opts.Notes} issueJSON, _ := json.Marshal(extendedIssue) fmt.Fprintln(opts.IO.StdOut, string(issueJSON)) diff --git a/commands/issuable/view/issuable_view_test.go b/commands/issuable/view/issuable_view_test.go index 0fd24f3ee..e5071c690 100644 --- a/commands/issuable/view/issuable_view_test.go +++ b/commands/issuable/view/issuable_view_test.go @@ -2,6 +2,7 @@ package view import ( "bytes" + "encoding/json" "fmt" "os/exec" "regexp" @@ -499,3 +500,15 @@ func Test_assigneesList(t *testing.T) { }) } } + +func TestIssueViewJSON(t *testing.T) { + cmd := NewCmdView(stubFactory, issuable.TypeIssue) + + output, err := cmdtest.ExecuteCommand(cmd, "1 -F json", stdout, stderr) + if err != nil { + t.Errorf("error running command `issue view 1 -F json`: %v", err) + } + + assert.True(t, json.Valid([]byte(output.String()))) + assert.Empty(t, output.Stderr()) +} diff --git a/commands/label/list/label_list_test.go b/commands/label/list/label_list_test.go index 54baf6d82..eec106516 100644 --- a/commands/label/list/label_list_test.go +++ b/commands/label/list/label_list_test.go @@ -4,8 +4,6 @@ import ( "net/http" "testing" - "gitlab.com/gitlab-org/cli/pkg/iostreams" - "github.com/MakeNowJust/heredoc" "github.com/stretchr/testify/assert" @@ -14,8 +12,8 @@ import ( "gitlab.com/gitlab-org/cli/test" ) -func runCommand(rt http.RoundTripper) (*test.CmdOut, error) { - ios, _, stdout, stderr := iostreams.Test() +func runCommand(rt http.RoundTripper, cli string) (*test.CmdOut, error) { + ios, _, stdout, stderr := cmdtest.InitIOStreams(true, "") factory := cmdtest.InitFactory(ios, rt) // TODO: shouldn't be there but the stub doesn't work without it @@ -23,11 +21,7 @@ func runCommand(rt http.RoundTripper) (*test.CmdOut, error) { cmd := NewCmdList(factory) - _, err := cmd.ExecuteC() - return &test.CmdOut{ - OutBuf: stdout, - ErrBuf: stderr, - }, err + return cmdtest.ExecuteCommand(cmd, cli, stdout, stderr) } func TestLabelList(t *testing.T) { @@ -58,7 +52,7 @@ func TestLabelList(t *testing.T) { ] `)) - output, err := runCommand(fakeHTTP) + output, err := runCommand(fakeHTTP, "") if err != nil { t.Errorf("error running command `label list`: %v", err) } @@ -74,3 +68,51 @@ func TestLabelList(t *testing.T) { `), out) assert.Empty(t, output.Stderr()) } + +func TestLabelListJSON(t *testing.T) { + fakeHTTP := httpmock.New() + fakeHTTP.MatchURL = httpmock.PathAndQuerystring + defer fakeHTTP.Verify(t) + + expectedBody := `[ + { + "id": 29739671, + "name": "my label", + "color": "#00b140", + "text_color": "#FFFFFF", + "description": "Simple label", + "open_issues_count": 0, + "closed_issues_count": 0, + "open_merge_requests_count": 0, + "subscribed": false, + "priority": 0, + "is_project_label": true + } +]` + + fakeHTTP.RegisterResponder(http.MethodGet, "/api/v4/projects/OWNER%2FREPO/labels?page=1&per_page=30&with_counts=true", + httpmock.NewStringResponse(http.StatusOK, `[ + { + "id": 29739671, + "name": "my label", + "description": "Simple label", + "description_html": "Simple label", + "text_color": "#FFFFFF", + "color": "#00b140", + "open_issues_count": 0, + "closed_issues_count": 0, + "open_merge_requests_count": 0, + "subscribed": false, + "priority": null, + "is_project_label": true + } +]`)) + + output, err := runCommand(fakeHTTP, "-F json") + if err != nil { + t.Errorf("error running command `label list -F json`: %v", err) + } + + assert.JSONEq(t, expectedBody, output.String()) + assert.Empty(t, output.Stderr()) +} diff --git a/commands/mr/list/mr_list_test.go b/commands/mr/list/mr_list_test.go index 8354461f3..8f06720db 100644 --- a/commands/mr/list/mr_list_test.go +++ b/commands/mr/list/mr_list_test.go @@ -3,6 +3,7 @@ package list import ( "fmt" "net/http" + "os" "strings" "testing" @@ -355,3 +356,31 @@ func TestMergeRequestList_labels(t *testing.T) { }) } } + +func TestMrListJSON(t *testing.T) { + fakeHTTP := httpmock.New() + fakeHTTP.MatchURL = httpmock.PathAndQuerystring + defer fakeHTTP.Verify(t) + + fakeHTTP.RegisterResponder(http.MethodGet, "/api/v4/projects/OWNER/REPO/merge_requests?page=1&per_page=30&state=opened", + httpmock.NewFileResponse(http.StatusOK, "./testdata/mrList.json")) + + output, err := runCommand(fakeHTTP, true, "-F json", nil, "") + if err != nil { + t.Errorf("error running command `mr list -F json`: %v", err) + } + + if err != nil { + panic(err) + } + + b, err := os.ReadFile("./testdata/mrList.json") + if err != nil { + fmt.Print(err) + } + + expectedOut := string(b) + + assert.JSONEq(t, expectedOut, output.String()) + assert.Empty(t, output.Stderr()) +} diff --git a/test/json_output_data/mr/list/testdata/mr_list-0.json b/commands/mr/list/testdata/mrList.json similarity index 60% rename from test/json_output_data/mr/list/testdata/mr_list-0.json rename to commands/mr/list/testdata/mrList.json index 5ebec2635..29ea87977 100644 --- a/test/json_output_data/mr/list/testdata/mr_list-0.json +++ b/commands/mr/list/testdata/mrList.json @@ -2,159 +2,210 @@ { "id": 136297744, "iid": 4, + "target_branch": "main", + "source_branch": "1-fake-issue-3", "project_id": 29316529, "title": "Draft: Resolve \"fake issue\"", - "description": "Closes #1", "state": "opened", "created_at": "2022-01-20T21:20:50.665Z", - "updated_at": "2022-01-20T21:47:54.110Z", - "merged_by": null, - "merge_user": null, - "merged_at": null, - "closed_by": null, - "closed_at": null, - "target_branch": "main", - "source_branch": "1-fake-issue-3", - "user_notes_count": 0, + "updated_at": "2022-01-20T21:47:54.11Z", "upvotes": 0, "downvotes": 0, - "author": { + "author": + { "id": 8814129, "username": "OWNER", "name": "Some User", "state": "active", - "locked": false, + "created_at": null, "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", "web_url": "https://gitlab.com/OWNER" }, - "assignees": [ + "assignee": + { + "id": 8814129, + "username": "OWNER", + "name": "Some User", + "state": "active", + "created_at": null, + "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", + "web_url": "https://gitlab.com/OWNER" + }, + "assignees": + [ { "id": 8814129, "username": "OWNER", "name": "Some User", "state": "active", - "locked": false, + "created_at": null, "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", "web_url": "https://gitlab.com/OWNER" } ], - "assignee": { - "id": 8814129, - "username": "OWNER", - "name": "Some User", - "state": "active", - "locked": false, - "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", - "web_url": "https://gitlab.com/OWNER" - }, - "reviewers": [], + "reviewers": + [], "source_project_id": 29316529, "target_project_id": 29316529, - "labels": [], + "labels": "", + "label_details": null, + "description": "Closes #1", "draft": true, "work_in_progress": true, "milestone": null, "merge_when_pipeline_succeeds": false, - "merge_status": "can_be_merged", "detailed_merge_status": "draft_status", + "merge_error": "", + "merged_by": null, + "merged_at": null, + "closed_by": null, + "closed_at": null, + "subscribed": false, "sha": "44eb489568f7cb1a5a730fce6b247cd3797172ca", - "merge_commit_sha": null, - "squash_commit_sha": null, - "discussion_locked": null, - "should_remove_source_branch": null, + "merge_commit_sha": "", + "squash_commit_sha": "", + "user_notes_count": 0, + "changes_count": "", + "should_remove_source_branch": false, "force_remove_source_branch": true, - "prepared_at": "2022-01-20T21:20:50.665Z", - "reference": "!4", - "references": { + "allow_collaboration": false, + "web_url": "https://gitlab.com/OWNER/REPO/-/merge_requests/4", + "references": + { "short": "!4", "relative": "!4", "full": "OWNER/REPO!4" }, - "web_url": "https://gitlab.com/OWNER/REPO/-/merge_requests/4", - "time_stats": { + "discussion_locked": false, + "changes": null, + "user": + { + "can_merge": false + }, + "time_stats": + { + "human_time_estimate": "", + "human_total_time_spent": "", "time_estimate": 0, - "total_time_spent": 0, - "human_time_estimate": null, - "human_total_time_spent": null + "total_time_spent": 0 }, "squash": false, - "squash_on_merge": false, - "task_completion_status": { + "pipeline": null, + "head_pipeline": null, + "diff_refs": + { + "base_sha": "", + "head_sha": "", + "start_sha": "" + }, + "diverged_commits_count": 0, + "rebase_in_progress": false, + "approvals_before_merge": 0, + "reference": "!4", + "first_contribution": false, + "task_completion_status": + { "count": 0, "completed_count": 0 }, "has_conflicts": false, "blocking_discussions_resolved": true, - "approvals_before_merge": null + "overflow": false, + "merge_status": "can_be_merged" }, { "id": 135750125, "iid": 1, + "target_branch": "main", + "source_branch": "OWNER-main-patch-25608", "project_id": 29316529, "title": "Update .gitlab-ci.yml", - "description": "", "state": "opened", - "created_at": "2022-01-18T17:02:23.270Z", + "created_at": "2022-01-18T17:02:23.27Z", "updated_at": "2022-01-18T18:06:50.054Z", - "merged_by": null, - "merge_user": null, - "merged_at": null, - "closed_by": null, - "closed_at": null, - "target_branch": "main", - "source_branch": "OWNER-main-patch-25608", - "user_notes_count": 0, "upvotes": 0, "downvotes": 0, - "author": { + "author": + { "id": 8814129, "username": "OWNER", "name": "Some User", "state": "active", - "locked": false, + "created_at": null, "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", "web_url": "https://gitlab.com/OWNER" }, - "assignees": [], "assignee": null, - "reviewers": [], + "assignees": + [], + "reviewers": + [], "source_project_id": 29316529, "target_project_id": 29316529, - "labels": [], + "labels": "", + "label_details": null, + "description": "", "draft": false, "work_in_progress": false, "milestone": null, "merge_when_pipeline_succeeds": false, - "merge_status": "can_be_merged", "detailed_merge_status": "mergeable", + "merge_error": "", + "merged_by": null, + "merged_at": null, + "closed_by": null, + "closed_at": null, + "subscribed": false, "sha": "123f34ebfd5d97ef562974e55e01b83f06ae7b4a", - "merge_commit_sha": null, - "squash_commit_sha": null, - "discussion_locked": null, - "should_remove_source_branch": null, + "merge_commit_sha": "", + "squash_commit_sha": "", + "user_notes_count": 0, + "changes_count": "", + "should_remove_source_branch": false, "force_remove_source_branch": true, - "prepared_at": "2022-01-18T17:02:23.270Z", - "reference": "!1", - "references": { + "allow_collaboration": false, + "web_url": "https://gitlab.com/OWNER/REPO/-/merge_requests/1", + "references": + { "short": "!1", "relative": "!1", "full": "OWNER/REPO!1" }, - "web_url": "https://gitlab.com/OWNER/REPO/-/merge_requests/1", - "time_stats": { + "discussion_locked": false, + "changes": null, + "user": + { + "can_merge": false + }, + "time_stats": + { + "human_time_estimate": "", + "human_total_time_spent": "", "time_estimate": 0, - "total_time_spent": 0, - "human_time_estimate": null, - "human_total_time_spent": null + "total_time_spent": 0 }, "squash": false, - "squash_on_merge": false, - "task_completion_status": { + "pipeline": null, + "head_pipeline": null, + "diff_refs": + { + "base_sha": "", + "head_sha": "", + "start_sha": "" + }, + "diverged_commits_count": 0, + "rebase_in_progress": false, + "approvals_before_merge": 0, + "reference": "!1", + "first_contribution": false, + "task_completion_status": + { "count": 0, "completed_count": 0 }, "has_conflicts": false, "blocking_discussions_resolved": true, - "approvals_before_merge": null + "overflow": false, + "merge_status": "can_be_merged" } -] +] \ No newline at end of file diff --git a/commands/mr/view/mr_view.go b/commands/mr/view/mr_view.go index deed06d26..715c107c2 100644 --- a/commands/mr/view/mr_view.go +++ b/commands/mr/view/mr_view.go @@ -294,7 +294,6 @@ func rawMRPreview(opts *ViewOpts, mr *gitlab.MergeRequest, notes []*gitlab.Note) } func printJSONMR(opts *ViewOpts, mr *gitlab.MergeRequest, notes []*gitlab.Note) error { - // var notes []gitlab.Note if opts.ShowComments { extendedMR := MRWithNotes{mr, notes} mrJSON, _ := json.Marshal(extendedMR) diff --git a/commands/mr/view/mr_view_test.go b/commands/mr/view/mr_view_test.go index c39be3961..b40c635d5 100644 --- a/commands/mr/view/mr_view_test.go +++ b/commands/mr/view/mr_view_test.go @@ -2,6 +2,7 @@ package view import ( "bytes" + "encoding/json" "fmt" "os/exec" "regexp" @@ -465,3 +466,17 @@ func Test_reviewersList(t *testing.T) { }) } } + +func TestMrViewJSON(t *testing.T) { + cmd := NewCmdView(stubFactory) + stdout.Reset() + stderr.Reset() + + output, err := cmdtest.ExecuteCommand(cmd, "1 -F json", stdout, stderr) + if err != nil { + t.Errorf("error running command `mr view 1 -F json`: %v", err) + } + + assert.True(t, json.Valid([]byte(output.String()))) + assert.Empty(t, output.Stderr()) +} diff --git a/pkg/httpmock/stub.go b/pkg/httpmock/stub.go index 071ffc05e..7c1725fa8 100644 --- a/pkg/httpmock/stub.go +++ b/pkg/httpmock/stub.go @@ -3,7 +3,6 @@ package httpmock import ( "bytes" "encoding/json" - "fmt" "io" "net/http" "net/url" @@ -81,7 +80,6 @@ func NewFileResponse(status int, filename string) Responder { } func httpResponse(status int, req *http.Request, body io.Reader) *http.Response { - fmt.Fprintf(os.Stderr, ">> %s\n", req.URL.String()) return &http.Response{ StatusCode: status, Request: req, diff --git a/test/json_output_data/ci/get/testdata/ci_get-0.json b/test/json_output_data/ci/get/testdata/ci_get-0.json deleted file mode 100644 index 498f83972..000000000 --- a/test/json_output_data/ci/get/testdata/ci_get-0.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "id": 452959326, - "iid": 14, - "project_id": 29316529, - "sha": "44eb489568f7cb1a5a730fce6b247cd3797172ca", - "ref": "1-fake-issue-3", - "status": "success", - "source": "push", - "created_at": "2022-01-20T21:47:16.276Z", - "updated_at": "2022-01-20T21:47:31.358Z", - "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/452959326", - "before_sha": "001eb421e586a3f07f90aea102c8b2d4068ab5b6", - "tag": false, - "yaml_errors": null, - "user": { - "id": 8814129, - "username": "OWNER", - "name": "Some User", - "state": "active", - "locked": false, - "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", - "web_url": "https://gitlab.com/OWNER" - }, - "started_at": "2022-01-20T21:47:17.448Z", - "finished_at": "2022-01-20T21:47:31.350Z", - "committed_at": null, - "duration": 14, - "queued_duration": 1, - "coverage": null, - "detailed_status": { - "icon": "status_success", - "text": "Passed", - "label": "passed", - "group": "success", - "tooltip": "passed", - "has_details": true, - "details_path": "/OWNER/REPO/-/pipelines/452959326", - "illustration": null, - "favicon": "/assets/ci_favicons/favicon_status_success-8451333011eee8ce9f2ab25dc487fe24a8758c694827a582f17f42b0a90446a2.png" - }, - "name": null -} diff --git a/test/json_output_data/ci/get/testdata/ci_get-0.request b/test/json_output_data/ci/get/testdata/ci_get-0.request deleted file mode 100644 index 0d1edd5a6..000000000 --- a/test/json_output_data/ci/get/testdata/ci_get-0.request +++ /dev/null @@ -1,4 +0,0 @@ -{ - "url": "/api/v4/projects/OWNER%2FREPO/pipelines/452959326", - "method": "GET" -} diff --git a/test/json_output_data/ci/get/testdata/ci_get-1.json b/test/json_output_data/ci/get/testdata/ci_get-1.json deleted file mode 100644 index 657b6ae95..000000000 --- a/test/json_output_data/ci/get/testdata/ci_get-1.json +++ /dev/null @@ -1,102 +0,0 @@ -[ - { - "id": 1999017704, - "status": "success", - "stage": "test", - "name": "test_vars", - "ref": "1-fake-issue-3", - "tag": false, - "coverage": null, - "allow_failure": false, - "created_at": "2022-01-20T21:47:16.291Z", - "started_at": "2022-01-20T21:47:16.693Z", - "finished_at": "2022-01-20T21:47:31.274Z", - "erased_at": null, - "duration": 14.580467, - "queued_duration": 0.211715, - "user": { - "id": 8814129, - "username": "OWNER", - "name": "Some User", - "state": "active", - "locked": false, - "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", - "web_url": "https://gitlab.com/OWNER", - "created_at": "2021-05-03T14:58:50.059Z", - "bio": "", - "location": "Canada", - "public_email": "", - "skype": "", - "linkedin": "", - "twitter": "", - "discord": "", - "website_url": "", - "organization": "GitLab", - "job_title": "Sr Backend Engineer", - "pronouns": "", - "bot": false, - "work_information": "Sr Backend Engineer at GitLab", - "followers": 2, - "following": 0, - "local_time": "3:30 PM" - }, - "commit": { - "id": "44eb489568f7cb1a5a730fce6b247cd3797172ca", - "short_id": "44eb4895", - "created_at": "2022-01-20T21:47:15.000+00:00", - "parent_ids": [ - "001eb421e586a3f07f90aea102c8b2d4068ab5b6" - ], - "title": "Add new file", - "message": "Add new file", - "author_name": "Some User", - "author_email": "OWNER@gitlab.com", - "authored_date": "2022-01-20T21:47:15.000+00:00", - "committer_name": "Some User", - "committer_email": "OWNER@gitlab.com", - "committed_date": "2022-01-20T21:47:15.000+00:00", - "trailers": {}, - "extended_trailers": {}, - "web_url": "https://gitlab.com/OWNER/REPO/-/commit/44eb489568f7cb1a5a730fce6b247cd3797172ca" - }, - "pipeline": { - "id": 452959326, - "iid": 14, - "project_id": 29316529, - "sha": "44eb489568f7cb1a5a730fce6b247cd3797172ca", - "ref": "1-fake-issue-3", - "status": "success", - "source": "push", - "created_at": "2022-01-20T21:47:16.276Z", - "updated_at": "2022-01-20T21:47:31.358Z", - "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/452959326" - }, - "web_url": "https://gitlab.com/OWNER/REPO/-/jobs/1999017704", - "project": { - "ci_job_token_scope_enabled": false - }, - "artifacts": [ - { - "file_type": "trace", - "size": 2770, - "filename": "job.log", - "file_format": null - } - ], - "runner": { - "id": 12270859, - "description": "5-green.saas-linux-small-amd64.runners-manager.gitlab.com/default", - "ip_address": "10.1.5.249", - "active": true, - "paused": false, - "is_shared": true, - "runner_type": "instance_type", - "name": "gitlab-runner", - "online": false, - "status": "offline" - }, - "artifacts_expire_at": null, - "archived": false, - "tag_list": [] - } -] diff --git a/test/json_output_data/ci/get/testdata/ci_get-1.request b/test/json_output_data/ci/get/testdata/ci_get-1.request deleted file mode 100644 index d9ad0906a..000000000 --- a/test/json_output_data/ci/get/testdata/ci_get-1.request +++ /dev/null @@ -1,4 +0,0 @@ -{ - "url": "/api/v4/projects/OWNER%2FREPO/pipelines/452959326/jobs?per_page=100", - "method": "GET" -} diff --git a/test/json_output_data/ci/get/testdata/ci_get.result b/test/json_output_data/ci/get/testdata/ci_get.result deleted file mode 100644 index f997aec80..000000000 --- a/test/json_output_data/ci/get/testdata/ci_get.result +++ /dev/null @@ -1 +0,0 @@ -{"id":452959326,"iid":14,"project_id":29316529,"status":"success","source":"push","ref":"1-fake-issue-3","sha":"44eb489568f7cb1a5a730fce6b247cd3797172ca","before_sha":"001eb421e586a3f07f90aea102c8b2d4068ab5b6","tag":false,"yaml_errors":"","user":{"id":8814129,"username":"OWNER","name":"Some User","state":"active","created_at":null,"avatar_url":"https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png","web_url":"https://gitlab.com/OWNER"},"updated_at":"2022-01-20T21:47:31.358Z","created_at":"2022-01-20T21:47:16.276Z","started_at":"2022-01-20T21:47:17.448Z","finished_at":"2022-01-20T21:47:31.35Z","committed_at":null,"duration":14,"queued_duration":1,"coverage":"","web_url":"https://gitlab.com/OWNER/REPO/-/pipelines/452959326","detailed_status":{"icon":"status_success","text":"Passed","label":"passed","group":"success","tooltip":"passed","has_details":true,"details_path":"/OWNER/REPO/-/pipelines/452959326","illustration":{"image":""},"favicon":"/assets/ci_favicons/favicon_status_success-8451333011eee8ce9f2ab25dc487fe24a8758c694827a582f17f42b0a90446a2.png"},"jobs":[{"commit":{"id":"44eb489568f7cb1a5a730fce6b247cd3797172ca","short_id":"44eb4895","title":"Add new file","author_name":"Some User","author_email":"OWNER@gitlab.com","authored_date":"2022-01-20T21:47:15Z","committer_name":"Some User","committer_email":"OWNER@gitlab.com","committed_date":"2022-01-20T21:47:15Z","created_at":"2022-01-20T21:47:15Z","message":"Add new file","parent_ids":["001eb421e586a3f07f90aea102c8b2d4068ab5b6"],"stats":null,"status":null,"last_pipeline":null,"project_id":0,"trailers":{},"web_url":"https://gitlab.com/OWNER/REPO/-/commit/44eb489568f7cb1a5a730fce6b247cd3797172ca"},"coverage":0,"allow_failure":false,"created_at":"2022-01-20T21:47:16.291Z","started_at":"2022-01-20T21:47:16.693Z","finished_at":"2022-01-20T21:47:31.274Z","erased_at":null,"duration":14.580467,"queued_duration":0.211715,"artifacts_expire_at":null,"tag_list":[],"id":1999017704,"name":"test_vars","pipeline":{"id":452959326,"project_id":29316529,"ref":"1-fake-issue-3","sha":"44eb489568f7cb1a5a730fce6b247cd3797172ca","status":"success"},"ref":"1-fake-issue-3","artifacts":[{"file_type":"trace","filename":"job.log","size":2770,"file_format":""}],"artifacts_file":{"filename":"","size":0},"runner":{"id":12270859,"description":"5-green.saas-linux-small-amd64.runners-manager.gitlab.com/default","active":true,"is_shared":true,"name":"gitlab-runner"},"stage":"test","status":"success","failure_reason":"","tag":false,"web_url":"https://gitlab.com/OWNER/REPO/-/jobs/1999017704","project":{"id":0,"description":"","default_branch":"","public":false,"visibility":"","ssh_url_to_repo":"","http_url_to_repo":"","web_url":"","readme_url":"","tag_list":null,"topics":null,"owner":null,"name":"","name_with_namespace":"","path":"","path_with_namespace":"","issues_enabled":false,"open_issues_count":0,"merge_requests_enabled":false,"approvals_before_merge":0,"jobs_enabled":false,"wiki_enabled":false,"snippets_enabled":false,"resolve_outdated_diff_discussions":false,"container_registry_enabled":false,"container_registry_access_level":"","creator_id":0,"namespace":null,"permissions":null,"marked_for_deletion_at":null,"empty_repo":false,"archived":false,"avatar_url":"","license_url":"","license":null,"shared_runners_enabled":false,"group_runners_enabled":false,"runner_token_expiration_interval":0,"forks_count":0,"star_count":0,"runners_token":"","allow_merge_on_skipped_pipeline":false,"only_allow_merge_if_pipeline_succeeds":false,"only_allow_merge_if_all_discussions_are_resolved":false,"remove_source_branch_after_merge":false,"printing_merge_request_link_enabled":false,"lfs_enabled":false,"repository_storage":"","request_access_enabled":false,"merge_method":"","can_create_merge_request_in":false,"forked_from_project":null,"mirror":false,"mirror_user_id":0,"mirror_trigger_builds":false,"only_mirror_protected_branches":false,"mirror_overwrites_diverged_branches":false,"packages_enabled":false,"service_desk_enabled":false,"service_desk_address":"","issues_access_level":"","repository_access_level":"","merge_requests_access_level":"","forking_access_level":"","wiki_access_level":"","builds_access_level":"","snippets_access_level":"","pages_access_level":"","operations_access_level":"","analytics_access_level":"","environments_access_level":"","feature_flags_access_level":"","infrastructure_access_level":"","monitor_access_level":"","autoclose_referenced_issues":false,"suggestion_commit_message":"","squash_option":"","shared_with_groups":null,"statistics":null,"import_url":"","import_type":"","import_status":"","import_error":"","ci_default_git_depth":0,"ci_forward_deployment_enabled":false,"ci_separated_caches":false,"ci_job_token_scope_enabled":false,"ci_opt_in_jwt":false,"ci_allow_fork_pipelines_to_run_in_parent_project":false,"public_jobs":false,"build_timeout":0,"auto_cancel_pending_pipelines":"","ci_config_path":"","custom_attributes":null,"compliance_frameworks":null,"build_coverage_regex":"","issues_template":"","merge_requests_template":"","issue_branch_template":"","keep_latest_artifact":false,"merge_pipelines_enabled":false,"merge_trains_enabled":false,"restrict_user_defined_variables":false,"merge_commit_template":"","squash_commit_template":"","auto_devops_deploy_strategy":"","auto_devops_enabled":false,"build_git_strategy":"","emails_enabled":false,"external_authorization_classification_label":"","requirements_enabled":false,"requirements_access_level":"","security_and_compliance_enabled":false,"security_and_compliance_access_level":"","mr_default_target_self":false,"emails_disabled":false,"public_builds":false},"user":{"id":8814129,"username":"OWNER","email":"","name":"Some User","state":"active","web_url":"https://gitlab.com/OWNER","created_at":"2021-05-03T14:58:50.059Z","bio":"","bot":false,"location":"Canada","public_email":"","skype":"","linkedin":"","twitter":"","website_url":"","organization":"GitLab","job_title":"Sr Backend Engineer","extern_uid":"","provider":"","theme_id":0,"last_activity_on":null,"color_scheme_id":0,"is_admin":false,"avatar_url":"https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png","can_create_group":false,"can_create_project":false,"projects_limit":0,"current_sign_in_at":null,"current_sign_in_ip":null,"last_sign_in_at":null,"last_sign_in_ip":null,"confirmed_at":null,"two_factor_enabled":false,"note":"","identities":null,"external":false,"private_profile":false,"shared_runners_minutes_limit":0,"extra_shared_runners_minutes_limit":0,"using_license_seat":false,"custom_attributes":null,"namespace_id":0}}],"variables":null} diff --git a/test/json_output_data/ci/list/testdata/ci_list-0.json b/test/json_output_data/ci/list/testdata/ci_list-0.json deleted file mode 100644 index abe1eb2e5..000000000 --- a/test/json_output_data/ci/list/testdata/ci_list-0.json +++ /dev/null @@ -1,184 +0,0 @@ -[ - { - "id": 452959326, - "iid": 14, - "project_id": 29316529, - "sha": "44eb489568f7cb1a5a730fce6b247cd3797172ca", - "ref": "1-fake-issue-3", - "status": "success", - "source": "push", - "created_at": "2022-01-20T21:47:16.276Z", - "updated_at": "2022-01-20T21:47:31.358Z", - "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/452959326", - "name": null - }, - { - "id": 452944621, - "iid": 13, - "project_id": 29316529, - "sha": "001eb421e586a3f07f90aea102c8b2d4068ab5b6", - "ref": "1-fake-issue-3", - "status": "success", - "source": "push", - "created_at": "2022-01-20T21:20:50.971Z", - "updated_at": "2022-01-20T21:21:04.802Z", - "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/452944621", - "name": null - }, - { - "id": 452941417, - "iid": 12, - "project_id": 29316529, - "sha": "001eb421e586a3f07f90aea102c8b2d4068ab5b6", - "ref": "1-fake-issue", - "status": "success", - "source": "push", - "created_at": "2022-01-20T21:15:42.546Z", - "updated_at": "2022-01-20T21:15:55.200Z", - "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/452941417", - "name": null - }, - { - "id": 452939664, - "iid": 11, - "project_id": 29316529, - "sha": "001eb421e586a3f07f90aea102c8b2d4068ab5b6", - "ref": "1-mr", - "status": "success", - "source": "push", - "created_at": "2022-01-20T21:12:35.048Z", - "updated_at": "2022-01-20T21:12:50.132Z", - "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/452939664", - "name": null - }, - { - "id": 450719821, - "iid": 10, - "project_id": 29316529, - "sha": "123f34ebfd5d97ef562974e55e01b83f06ae7b4a", - "ref": "OWNER-main-patch-25608", - "status": "success", - "source": "push", - "created_at": "2022-01-18T18:06:49.629Z", - "updated_at": "2022-01-18T18:08:09.708Z", - "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/450719821", - "name": null - }, - { - "id": 450714758, - "iid": 9, - "project_id": 29316529, - "sha": "f288fd8d797a05c2946eb5d675f9d4438a150bec", - "ref": "OWNER-main-patch-25608", - "status": "success", - "source": "push", - "created_at": "2022-01-18T18:04:03.546Z", - "updated_at": "2022-01-18T18:05:23.843Z", - "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/450714758", - "name": null - }, - { - "id": 450707660, - "iid": 8, - "project_id": 29316529, - "sha": "afe2714d50f156567ab87c2434cd901de7d341dc", - "ref": "OWNER-main-patch-25608", - "status": "success", - "source": "push", - "created_at": "2022-01-18T18:00:31.663Z", - "updated_at": "2022-01-18T18:01:53.086Z", - "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/450707660", - "name": null - }, - { - "id": 450615878, - "iid": 7, - "project_id": 29316529, - "sha": "a4030d817a2881f5998e6466b9ba90914aecfb18", - "ref": "OWNER-main-patch-25608", - "status": "success", - "source": "push", - "created_at": "2022-01-18T17:02:16.204Z", - "updated_at": "2022-01-18T17:03:22.021Z", - "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/450615878", - "name": null - }, - { - "id": 364128214, - "iid": 6, - "project_id": 29316529, - "sha": "001eb421e586a3f07f90aea102c8b2d4068ab5b6", - "ref": "main", - "status": "success", - "source": "push", - "created_at": "2021-09-02T14:19:52.731Z", - "updated_at": "2021-09-02T14:20:07.800Z", - "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/364128214", - "name": null - }, - { - "id": 364109593, - "iid": 5, - "project_id": 29316529, - "sha": "2a10724040f892e45917e4aef03cdb821e98bd99", - "ref": "main", - "status": "success", - "source": "web", - "created_at": "2021-09-02T13:58:21.181Z", - "updated_at": "2021-09-02T13:58:35.804Z", - "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/364109593", - "name": null - }, - { - "id": 364109341, - "iid": 4, - "project_id": 29316529, - "sha": "2a10724040f892e45917e4aef03cdb821e98bd99", - "ref": "main", - "status": "success", - "source": "push", - "created_at": "2021-09-02T13:57:59.126Z", - "updated_at": "2021-09-02T13:58:11.734Z", - "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/364109341", - "name": null - }, - { - "id": 364104462, - "iid": 3, - "project_id": 29316529, - "sha": "65fb4980734c4b84fa1f7c934c92f747a6fe3ed0", - "ref": "main", - "status": "success", - "source": "web", - "created_at": "2021-09-02T13:51:43.615Z", - "updated_at": "2021-09-02T13:51:57.057Z", - "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/364104462", - "name": null - }, - { - "id": 364102457, - "iid": 2, - "project_id": 29316529, - "sha": "65fb4980734c4b84fa1f7c934c92f747a6fe3ed0", - "ref": "main", - "status": "success", - "source": "push", - "created_at": "2021-09-02T13:48:58.178Z", - "updated_at": "2021-09-02T13:49:10.689Z", - "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/364102457", - "name": null - }, - { - "id": 364098384, - "iid": 1, - "project_id": 29316529, - "sha": "6bd3a42163672bb5341075021d74231c3d75d4b8", - "ref": "main", - "status": "skipped", - "source": "push", - "created_at": "2021-09-02T13:43:57.758Z", - "updated_at": "2021-09-02T13:43:57.758Z", - "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/364098384", - "name": null - } -] diff --git a/test/json_output_data/ci/list/testdata/ci_list-0.request b/test/json_output_data/ci/list/testdata/ci_list-0.request deleted file mode 100644 index 33b707893..000000000 --- a/test/json_output_data/ci/list/testdata/ci_list-0.request +++ /dev/null @@ -1,4 +0,0 @@ -{ - "url": "/api/v4/projects/OWNER%2FREPO/pipelines?order_by=id&page=1&per_page=30&sort=desc", - "method": "GET" -} diff --git a/test/json_output_data/ci/list/testdata/ci_list.result b/test/json_output_data/ci/list/testdata/ci_list.result deleted file mode 100644 index 423df6ce9..000000000 --- a/test/json_output_data/ci/list/testdata/ci_list.result +++ /dev/null @@ -1 +0,0 @@ -[{"id":452959326,"iid":14,"project_id":29316529,"status":"success","source":"push","ref":"1-fake-issue-3","sha":"44eb489568f7cb1a5a730fce6b247cd3797172ca","web_url":"https://gitlab.com/OWNER/REPO/-/pipelines/452959326","updated_at":"2022-01-20T21:47:31.358Z","created_at":"2022-01-20T21:47:16.276Z"},{"id":452944621,"iid":13,"project_id":29316529,"status":"success","source":"push","ref":"1-fake-issue-3","sha":"001eb421e586a3f07f90aea102c8b2d4068ab5b6","web_url":"https://gitlab.com/OWNER/REPO/-/pipelines/452944621","updated_at":"2022-01-20T21:21:04.802Z","created_at":"2022-01-20T21:20:50.971Z"},{"id":452941417,"iid":12,"project_id":29316529,"status":"success","source":"push","ref":"1-fake-issue","sha":"001eb421e586a3f07f90aea102c8b2d4068ab5b6","web_url":"https://gitlab.com/OWNER/REPO/-/pipelines/452941417","updated_at":"2022-01-20T21:15:55.2Z","created_at":"2022-01-20T21:15:42.546Z"},{"id":452939664,"iid":11,"project_id":29316529,"status":"success","source":"push","ref":"1-mr","sha":"001eb421e586a3f07f90aea102c8b2d4068ab5b6","web_url":"https://gitlab.com/OWNER/REPO/-/pipelines/452939664","updated_at":"2022-01-20T21:12:50.132Z","created_at":"2022-01-20T21:12:35.048Z"},{"id":450719821,"iid":10,"project_id":29316529,"status":"success","source":"push","ref":"OWNER-main-patch-25608","sha":"123f34ebfd5d97ef562974e55e01b83f06ae7b4a","web_url":"https://gitlab.com/OWNER/REPO/-/pipelines/450719821","updated_at":"2022-01-18T18:08:09.708Z","created_at":"2022-01-18T18:06:49.629Z"},{"id":450714758,"iid":9,"project_id":29316529,"status":"success","source":"push","ref":"OWNER-main-patch-25608","sha":"f288fd8d797a05c2946eb5d675f9d4438a150bec","web_url":"https://gitlab.com/OWNER/REPO/-/pipelines/450714758","updated_at":"2022-01-18T18:05:23.843Z","created_at":"2022-01-18T18:04:03.546Z"},{"id":450707660,"iid":8,"project_id":29316529,"status":"success","source":"push","ref":"OWNER-main-patch-25608","sha":"afe2714d50f156567ab87c2434cd901de7d341dc","web_url":"https://gitlab.com/OWNER/REPO/-/pipelines/450707660","updated_at":"2022-01-18T18:01:53.086Z","created_at":"2022-01-18T18:00:31.663Z"},{"id":450615878,"iid":7,"project_id":29316529,"status":"success","source":"push","ref":"OWNER-main-patch-25608","sha":"a4030d817a2881f5998e6466b9ba90914aecfb18","web_url":"https://gitlab.com/OWNER/REPO/-/pipelines/450615878","updated_at":"2022-01-18T17:03:22.021Z","created_at":"2022-01-18T17:02:16.204Z"},{"id":364128214,"iid":6,"project_id":29316529,"status":"success","source":"push","ref":"main","sha":"001eb421e586a3f07f90aea102c8b2d4068ab5b6","web_url":"https://gitlab.com/OWNER/REPO/-/pipelines/364128214","updated_at":"2021-09-02T14:20:07.8Z","created_at":"2021-09-02T14:19:52.731Z"},{"id":364109593,"iid":5,"project_id":29316529,"status":"success","source":"web","ref":"main","sha":"2a10724040f892e45917e4aef03cdb821e98bd99","web_url":"https://gitlab.com/OWNER/REPO/-/pipelines/364109593","updated_at":"2021-09-02T13:58:35.804Z","created_at":"2021-09-02T13:58:21.181Z"},{"id":364109341,"iid":4,"project_id":29316529,"status":"success","source":"push","ref":"main","sha":"2a10724040f892e45917e4aef03cdb821e98bd99","web_url":"https://gitlab.com/OWNER/REPO/-/pipelines/364109341","updated_at":"2021-09-02T13:58:11.734Z","created_at":"2021-09-02T13:57:59.126Z"},{"id":364104462,"iid":3,"project_id":29316529,"status":"success","source":"web","ref":"main","sha":"65fb4980734c4b84fa1f7c934c92f747a6fe3ed0","web_url":"https://gitlab.com/OWNER/REPO/-/pipelines/364104462","updated_at":"2021-09-02T13:51:57.057Z","created_at":"2021-09-02T13:51:43.615Z"},{"id":364102457,"iid":2,"project_id":29316529,"status":"success","source":"push","ref":"main","sha":"65fb4980734c4b84fa1f7c934c92f747a6fe3ed0","web_url":"https://gitlab.com/OWNER/REPO/-/pipelines/364102457","updated_at":"2021-09-02T13:49:10.689Z","created_at":"2021-09-02T13:48:58.178Z"},{"id":364098384,"iid":1,"project_id":29316529,"status":"skipped","source":"push","ref":"main","sha":"6bd3a42163672bb5341075021d74231c3d75d4b8","web_url":"https://gitlab.com/OWNER/REPO/-/pipelines/364098384","updated_at":"2021-09-02T13:43:57.758Z","created_at":"2021-09-02T13:43:57.758Z"}] diff --git a/test/json_output_data/issue/list/testdata/issue_list-0.json b/test/json_output_data/issue/list/testdata/issue_list-0.json deleted file mode 100644 index c1067261d..000000000 --- a/test/json_output_data/issue/list/testdata/issue_list-0.json +++ /dev/null @@ -1,67 +0,0 @@ -[ - { - "id": 101004697, - "iid": 1, - "project_id": 29316529, - "title": "fake issue", - "description": "", - "state": "opened", - "created_at": "2022-01-20T21:11:56.452Z", - "updated_at": "2022-01-20T21:20:51.007Z", - "closed_at": null, - "closed_by": null, - "labels": [], - "milestone": null, - "assignees": [], - "author": { - "id": 8814129, - "username": "OWNER", - "name": "Some User", - "state": "active", - "locked": false, - "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", - "web_url": "https://gitlab.com/OWNER" - }, - "type": "ISSUE", - "assignee": null, - "user_notes_count": 0, - "merge_requests_count": 3, - "upvotes": 0, - "downvotes": 0, - "due_date": null, - "confidential": false, - "discussion_locked": null, - "issue_type": "issue", - "web_url": "https://gitlab.com/OWNER/REPO/-/issues/1", - "time_stats": { - "time_estimate": 0, - "total_time_spent": 0, - "human_time_estimate": null, - "human_total_time_spent": null - }, - "task_completion_status": { - "count": 0, - "completed_count": 0 - }, - "weight": null, - "blocking_issues_count": 0, - "has_tasks": true, - "task_status": "", - "_links": { - "self": "https://gitlab.com/api/v4/projects/29316529/issues/1", - "notes": "https://gitlab.com/api/v4/projects/29316529/issues/1/notes", - "award_emoji": "https://gitlab.com/api/v4/projects/29316529/issues/1/award_emoji", - "project": "https://gitlab.com/api/v4/projects/29316529", - "closed_as_duplicate_of": null - }, - "references": { - "short": "#1", - "relative": "#1", - "full": "OWNER/REPO#1" - }, - "severity": "UNKNOWN", - "moved_to_id": null, - "service_desk_reply_to": null, - "health_status": null - } -] diff --git a/test/json_output_data/issue/list/testdata/issue_list-0.request b/test/json_output_data/issue/list/testdata/issue_list-0.request deleted file mode 100644 index c32a9cfdf..000000000 --- a/test/json_output_data/issue/list/testdata/issue_list-0.request +++ /dev/null @@ -1,4 +0,0 @@ -{ - "url": "/api/v4/projects/OWNER%2FREPO/issues?in=title%2Cdescription&page=1&per_page=30&state=opened", - "method": "GET" -} diff --git a/test/json_output_data/issue/list/testdata/issue_list.result b/test/json_output_data/issue/list/testdata/issue_list.result deleted file mode 100644 index f07bbb232..000000000 --- a/test/json_output_data/issue/list/testdata/issue_list.result +++ /dev/null @@ -1 +0,0 @@ -[{"id":101004697,"iid":1,"external_id":"","state":"opened","description":"","health_status":"","author":{"id":8814129,"state":"active","web_url":"https://gitlab.com/OWNER","name":"Some User","avatar_url":"https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png","username":"OWNER"},"milestone":null,"project_id":29316529,"assignees":[],"assignee":null,"updated_at":"2022-01-20T21:20:51.007Z","closed_at":null,"closed_by":null,"title":"fake issue","created_at":"2022-01-20T21:11:56.452Z","moved_to_id":0,"labels":"","label_details":null,"upvotes":0,"downvotes":0,"due_date":null,"web_url":"https://gitlab.com/OWNER/REPO/-/issues/1","references":{"short":"#1","relative":"#1","full":"OWNER/REPO#1"},"time_stats":{"human_time_estimate":"","human_total_time_spent":"","time_estimate":0,"total_time_spent":0},"confidential":false,"weight":0,"discussion_locked":false,"issue_type":"issue","subscribed":false,"user_notes_count":0,"_links":{"self":"https://gitlab.com/api/v4/projects/29316529/issues/1","notes":"https://gitlab.com/api/v4/projects/29316529/issues/1/notes","award_emoji":"https://gitlab.com/api/v4/projects/29316529/issues/1/award_emoji","project":"https://gitlab.com/api/v4/projects/29316529"},"issue_link_id":0,"merge_requests_count":3,"epic_issue_id":0,"epic":null,"iteration":null,"task_completion_status":{"count":0,"completed_count":0}}] diff --git a/test/json_output_data/issue/view/testdata/issue_view-0.json b/test/json_output_data/issue/view/testdata/issue_view-0.json deleted file mode 100644 index fe1015a0d..000000000 --- a/test/json_output_data/issue/view/testdata/issue_view-0.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "id": 101004697, - "iid": 1, - "project_id": 29316529, - "title": "fake issue", - "description": "", - "state": "opened", - "created_at": "2022-01-20T21:11:56.452Z", - "updated_at": "2022-01-20T21:20:51.007Z", - "closed_at": null, - "closed_by": null, - "labels": [], - "milestone": null, - "assignees": [], - "author": { - "id": 8814129, - "username": "OWNER", - "name": "Some User", - "state": "active", - "locked": false, - "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", - "web_url": "https://gitlab.com/OWNER" - }, - "type": "ISSUE", - "assignee": null, - "user_notes_count": 0, - "merge_requests_count": 3, - "upvotes": 0, - "downvotes": 0, - "due_date": null, - "confidential": false, - "discussion_locked": null, - "issue_type": "issue", - "web_url": "https://gitlab.com/OWNER/REPO/-/issues/1", - "time_stats": { - "time_estimate": 0, - "total_time_spent": 0, - "human_time_estimate": null, - "human_total_time_spent": null - }, - "task_completion_status": { - "count": 0, - "completed_count": 0 - }, - "weight": null, - "blocking_issues_count": 0, - "has_tasks": true, - "task_status": "", - "_links": { - "self": "https://gitlab.com/api/v4/projects/29316529/issues/1", - "notes": "https://gitlab.com/api/v4/projects/29316529/issues/1/notes", - "award_emoji": "https://gitlab.com/api/v4/projects/29316529/issues/1/award_emoji", - "project": "https://gitlab.com/api/v4/projects/29316529", - "closed_as_duplicate_of": null - }, - "references": { - "short": "#1", - "relative": "#1", - "full": "OWNER/REPO#1" - }, - "severity": "UNKNOWN", - "subscribed": true, - "moved_to_id": null, - "service_desk_reply_to": null, - "health_status": null -} diff --git a/test/json_output_data/issue/view/testdata/issue_view-0.request b/test/json_output_data/issue/view/testdata/issue_view-0.request deleted file mode 100644 index cf55a48f4..000000000 --- a/test/json_output_data/issue/view/testdata/issue_view-0.request +++ /dev/null @@ -1,4 +0,0 @@ -{ - "url": "/api/v4/projects/OWNER%2FREPO/issues/1", - "method": "GET" -} diff --git a/test/json_output_data/issue/view/testdata/issue_view.result b/test/json_output_data/issue/view/testdata/issue_view.result deleted file mode 100644 index f25ff2a6a..000000000 --- a/test/json_output_data/issue/view/testdata/issue_view.result +++ /dev/null @@ -1 +0,0 @@ -{"id":101004697,"iid":1,"external_id":"","state":"opened","description":"","health_status":"","author":{"id":8814129,"state":"active","web_url":"https://gitlab.com/OWNER","name":"Some User","avatar_url":"https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png","username":"OWNER"},"milestone":null,"project_id":29316529,"assignees":[],"assignee":null,"updated_at":"2022-01-20T21:20:51.007Z","closed_at":null,"closed_by":null,"title":"fake issue","created_at":"2022-01-20T21:11:56.452Z","moved_to_id":0,"labels":"","label_details":null,"upvotes":0,"downvotes":0,"due_date":null,"web_url":"https://gitlab.com/OWNER/REPO/-/issues/1","references":{"short":"#1","relative":"#1","full":"OWNER/REPO#1"},"time_stats":{"human_time_estimate":"","human_total_time_spent":"","time_estimate":0,"total_time_spent":0},"confidential":false,"weight":0,"discussion_locked":false,"issue_type":"issue","subscribed":true,"user_notes_count":0,"_links":{"self":"https://gitlab.com/api/v4/projects/29316529/issues/1","notes":"https://gitlab.com/api/v4/projects/29316529/issues/1/notes","award_emoji":"https://gitlab.com/api/v4/projects/29316529/issues/1/award_emoji","project":"https://gitlab.com/api/v4/projects/29316529"},"issue_link_id":0,"merge_requests_count":3,"epic_issue_id":0,"epic":null,"iteration":null,"task_completion_status":{"count":0,"completed_count":0}} diff --git a/test/json_output_data/label/list/testdata/label_list-0.json b/test/json_output_data/label/list/testdata/label_list-0.json deleted file mode 100644 index 1bc1dd023..000000000 --- a/test/json_output_data/label/list/testdata/label_list-0.json +++ /dev/null @@ -1,16 +0,0 @@ -[ - { - "id": 29739671, - "name": "my label", - "description": "Simple label", - "description_html": "Simple label", - "text_color": "#FFFFFF", - "color": "#00b140", - "open_issues_count": 0, - "closed_issues_count": 0, - "open_merge_requests_count": 0, - "subscribed": false, - "priority": null, - "is_project_label": true - } -] diff --git a/test/json_output_data/label/list/testdata/label_list-0.request b/test/json_output_data/label/list/testdata/label_list-0.request deleted file mode 100644 index a9849b1c9..000000000 --- a/test/json_output_data/label/list/testdata/label_list-0.request +++ /dev/null @@ -1,4 +0,0 @@ -{ - "url": "/api/v4/projects/OWNER%2FREPO/labels?page=1&per_page=30&with_counts=true", - "method": "GET" -} diff --git a/test/json_output_data/label/list/testdata/label_list.result b/test/json_output_data/label/list/testdata/label_list.result deleted file mode 100644 index 2cca36850..000000000 --- a/test/json_output_data/label/list/testdata/label_list.result +++ /dev/null @@ -1 +0,0 @@ -[{"id":29739671,"name":"my label","color":"#00b140","text_color":"#FFFFFF","description":"Simple label","open_issues_count":0,"closed_issues_count":0,"open_merge_requests_count":0,"subscribed":false,"priority":0,"is_project_label":true}] diff --git a/test/json_output_data/mr/list/testdata/mr_list-0.request b/test/json_output_data/mr/list/testdata/mr_list-0.request deleted file mode 100644 index b489aa1dc..000000000 --- a/test/json_output_data/mr/list/testdata/mr_list-0.request +++ /dev/null @@ -1,4 +0,0 @@ -{ - "url": "/api/v4/projects/OWNER%2FREPO/merge_requests?page=1&per_page=30&state=opened", - "method": "GET" -} diff --git a/test/json_output_data/mr/list/testdata/mr_list.result b/test/json_output_data/mr/list/testdata/mr_list.result deleted file mode 100644 index d803df641..000000000 --- a/test/json_output_data/mr/list/testdata/mr_list.result +++ /dev/null @@ -1 +0,0 @@ -[{"id":136297744,"iid":4,"target_branch":"main","source_branch":"1-fake-issue-3","project_id":29316529,"title":"Draft: Resolve \"fake issue\"","state":"opened","created_at":"2022-01-20T21:20:50.665Z","updated_at":"2022-01-20T21:47:54.11Z","upvotes":0,"downvotes":0,"author":{"id":8814129,"username":"OWNER","name":"Some User","state":"active","created_at":null,"avatar_url":"https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png","web_url":"https://gitlab.com/OWNER"},"assignee":{"id":8814129,"username":"OWNER","name":"Some User","state":"active","created_at":null,"avatar_url":"https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png","web_url":"https://gitlab.com/OWNER"},"assignees":[{"id":8814129,"username":"OWNER","name":"Some User","state":"active","created_at":null,"avatar_url":"https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png","web_url":"https://gitlab.com/OWNER"}],"reviewers":[],"source_project_id":29316529,"target_project_id":29316529,"labels":"","label_details":null,"description":"Closes #1","draft":true,"work_in_progress":true,"milestone":null,"merge_when_pipeline_succeeds":false,"detailed_merge_status":"draft_status","merge_error":"","merged_by":null,"merged_at":null,"closed_by":null,"closed_at":null,"subscribed":false,"sha":"44eb489568f7cb1a5a730fce6b247cd3797172ca","merge_commit_sha":"","squash_commit_sha":"","user_notes_count":0,"changes_count":"","should_remove_source_branch":false,"force_remove_source_branch":true,"allow_collaboration":false,"web_url":"https://gitlab.com/OWNER/REPO/-/merge_requests/4","references":{"short":"!4","relative":"!4","full":"OWNER/REPO!4"},"discussion_locked":false,"changes":null,"user":{"can_merge":false},"time_stats":{"human_time_estimate":"","human_total_time_spent":"","time_estimate":0,"total_time_spent":0},"squash":false,"pipeline":null,"head_pipeline":null,"diff_refs":{"base_sha":"","head_sha":"","start_sha":""},"diverged_commits_count":0,"rebase_in_progress":false,"approvals_before_merge":0,"reference":"!4","first_contribution":false,"task_completion_status":{"count":0,"completed_count":0},"has_conflicts":false,"blocking_discussions_resolved":true,"overflow":false,"merge_status":"can_be_merged"},{"id":135750125,"iid":1,"target_branch":"main","source_branch":"OWNER-main-patch-25608","project_id":29316529,"title":"Update .gitlab-ci.yml","state":"opened","created_at":"2022-01-18T17:02:23.27Z","updated_at":"2022-01-18T18:06:50.054Z","upvotes":0,"downvotes":0,"author":{"id":8814129,"username":"OWNER","name":"Some User","state":"active","created_at":null,"avatar_url":"https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png","web_url":"https://gitlab.com/OWNER"},"assignee":null,"assignees":[],"reviewers":[],"source_project_id":29316529,"target_project_id":29316529,"labels":"","label_details":null,"description":"","draft":false,"work_in_progress":false,"milestone":null,"merge_when_pipeline_succeeds":false,"detailed_merge_status":"mergeable","merge_error":"","merged_by":null,"merged_at":null,"closed_by":null,"closed_at":null,"subscribed":false,"sha":"123f34ebfd5d97ef562974e55e01b83f06ae7b4a","merge_commit_sha":"","squash_commit_sha":"","user_notes_count":0,"changes_count":"","should_remove_source_branch":false,"force_remove_source_branch":true,"allow_collaboration":false,"web_url":"https://gitlab.com/OWNER/REPO/-/merge_requests/1","references":{"short":"!1","relative":"!1","full":"OWNER/REPO!1"},"discussion_locked":false,"changes":null,"user":{"can_merge":false},"time_stats":{"human_time_estimate":"","human_total_time_spent":"","time_estimate":0,"total_time_spent":0},"squash":false,"pipeline":null,"head_pipeline":null,"diff_refs":{"base_sha":"","head_sha":"","start_sha":""},"diverged_commits_count":0,"rebase_in_progress":false,"approvals_before_merge":0,"reference":"!1","first_contribution":false,"task_completion_status":{"count":0,"completed_count":0},"has_conflicts":false,"blocking_discussions_resolved":true,"overflow":false,"merge_status":"can_be_merged"}] diff --git a/test/json_output_data/mr/view/testdata/mr_view-0.json b/test/json_output_data/mr/view/testdata/mr_view-0.json deleted file mode 100644 index 16ecd35c5..000000000 --- a/test/json_output_data/mr/view/testdata/mr_view-0.json +++ /dev/null @@ -1,160 +0,0 @@ -{ - "id": 136297744, - "iid": 4, - "project_id": 29316529, - "title": "Draft: Resolve \"fake issue\"", - "description": "Closes #1", - "state": "opened", - "created_at": "2022-01-20T21:20:50.665Z", - "updated_at": "2022-01-20T21:47:54.110Z", - "merged_by": null, - "merge_user": null, - "merged_at": null, - "closed_by": null, - "closed_at": null, - "title_html": "Draft: Resolve \"fake issue\"", - "description_html": "

Closes #1

", - "target_branch": "main", - "source_branch": "1-fake-issue-3", - "user_notes_count": 0, - "upvotes": 0, - "downvotes": 0, - "author": { - "id": 8814129, - "username": "OWNER", - "name": "Some User", - "state": "active", - "locked": false, - "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", - "web_url": "https://gitlab.com/OWNER" - }, - "assignees": [ - { - "id": 8814129, - "username": "OWNER", - "name": "Some User", - "state": "active", - "locked": false, - "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", - "web_url": "https://gitlab.com/OWNER" - } - ], - "assignee": { - "id": 8814129, - "username": "OWNER", - "name": "Some User", - "state": "active", - "locked": false, - "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", - "web_url": "https://gitlab.com/OWNER" - }, - "reviewers": [], - "source_project_id": 29316529, - "target_project_id": 29316529, - "labels": [], - "draft": true, - "work_in_progress": true, - "milestone": null, - "merge_when_pipeline_succeeds": false, - "merge_status": "can_be_merged", - "detailed_merge_status": "draft_status", - "sha": "44eb489568f7cb1a5a730fce6b247cd3797172ca", - "merge_commit_sha": null, - "squash_commit_sha": null, - "discussion_locked": null, - "should_remove_source_branch": null, - "force_remove_source_branch": true, - "prepared_at": "2022-01-20T21:20:50.665Z", - "reference": "!4", - "references": { - "short": "!4", - "relative": "!4", - "full": "OWNER/REPO!4" - }, - "web_url": "https://gitlab.com/OWNER/REPO/-/merge_requests/4", - "time_stats": { - "time_estimate": 0, - "total_time_spent": 0, - "human_time_estimate": null, - "human_total_time_spent": null - }, - "squash": false, - "squash_on_merge": false, - "task_completion_status": { - "count": 0, - "completed_count": 0 - }, - "has_conflicts": false, - "blocking_discussions_resolved": true, - "approvals_before_merge": null, - "subscribed": true, - "changes_count": "1", - "latest_build_started_at": "2022-01-20T21:47:17.448Z", - "latest_build_finished_at": "2022-01-20T21:47:31.350Z", - "first_deployed_to_production_at": null, - "pipeline": { - "id": 452959326, - "iid": 14, - "project_id": 29316529, - "sha": "44eb489568f7cb1a5a730fce6b247cd3797172ca", - "ref": "1-fake-issue-3", - "status": "success", - "source": "push", - "created_at": "2022-01-20T21:47:16.276Z", - "updated_at": "2022-01-20T21:47:31.358Z", - "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/452959326" - }, - "head_pipeline": { - "id": 452959326, - "iid": 14, - "project_id": 29316529, - "sha": "44eb489568f7cb1a5a730fce6b247cd3797172ca", - "ref": "1-fake-issue-3", - "status": "success", - "source": "push", - "created_at": "2022-01-20T21:47:16.276Z", - "updated_at": "2022-01-20T21:47:31.358Z", - "web_url": "https://gitlab.com/OWNER/REPO/-/pipelines/452959326", - "before_sha": "001eb421e586a3f07f90aea102c8b2d4068ab5b6", - "tag": false, - "yaml_errors": null, - "user": { - "id": 8814129, - "username": "OWNER", - "name": "Some User", - "state": "active", - "locked": false, - "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", - "web_url": "https://gitlab.com/OWNER" - }, - "started_at": "2022-01-20T21:47:17.448Z", - "finished_at": "2022-01-20T21:47:31.350Z", - "committed_at": null, - "duration": 14, - "queued_duration": 1, - "coverage": null, - "detailed_status": { - "icon": "status_success", - "text": "Passed", - "label": "passed", - "group": "success", - "tooltip": "passed", - "has_details": true, - "details_path": "/OWNER/REPO/-/pipelines/452959326", - "illustration": null, - "favicon": "/assets/ci_favicons/favicon_status_success-8451333011eee8ce9f2ab25dc487fe24a8758c694827a582f17f42b0a90446a2.png" - } - }, - "diff_refs": { - "base_sha": "001eb421e586a3f07f90aea102c8b2d4068ab5b6", - "head_sha": "44eb489568f7cb1a5a730fce6b247cd3797172ca", - "start_sha": "001eb421e586a3f07f90aea102c8b2d4068ab5b6" - }, - "merge_error": null, - "rebase_in_progress": false, - "diverged_commits_count": 0, - "first_contribution": true, - "user": { - "can_merge": true - } -} diff --git a/test/json_output_data/mr/view/testdata/mr_view-0.request b/test/json_output_data/mr/view/testdata/mr_view-0.request deleted file mode 100644 index 6ba467a0d..000000000 --- a/test/json_output_data/mr/view/testdata/mr_view-0.request +++ /dev/null @@ -1,4 +0,0 @@ -{ - "url": "/api/v4/projects/OWNER%2FREPO/merge_requests/4?include_diverged_commits_count=true&include_rebase_in_progress=true&render_html=true", - "method": "GET" -} diff --git a/test/json_output_data/mr/view/testdata/mr_view-1.json b/test/json_output_data/mr/view/testdata/mr_view-1.json deleted file mode 100644 index 293243b53..000000000 --- a/test/json_output_data/mr/view/testdata/mr_view-1.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "approval_rules_overwritten": false, - "rules": [] -} diff --git a/test/json_output_data/mr/view/testdata/mr_view-1.request b/test/json_output_data/mr/view/testdata/mr_view-1.request deleted file mode 100644 index 92793768a..000000000 --- a/test/json_output_data/mr/view/testdata/mr_view-1.request +++ /dev/null @@ -1,4 +0,0 @@ -{ - "url": "/api/v4/projects/OWNER%2FREPO/merge_requests/4/approval_state", - "method": "GET" -} diff --git a/test/json_output_data/mr/view/testdata/mr_view.result b/test/json_output_data/mr/view/testdata/mr_view.result deleted file mode 100644 index c0c905996..000000000 --- a/test/json_output_data/mr/view/testdata/mr_view.result +++ /dev/null @@ -1 +0,0 @@ -{"id":136297744,"iid":4,"target_branch":"main","source_branch":"1-fake-issue-3","project_id":29316529,"title":"Draft: Resolve \"fake issue\"","state":"opened","created_at":"2022-01-20T21:20:50.665Z","updated_at":"2022-01-20T21:47:54.11Z","upvotes":0,"downvotes":0,"author":{"id":8814129,"username":"OWNER","name":"Some User","state":"active","created_at":null,"avatar_url":"https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png","web_url":"https://gitlab.com/OWNER"},"assignee":{"id":8814129,"username":"OWNER","name":"Some User","state":"active","created_at":null,"avatar_url":"https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png","web_url":"https://gitlab.com/OWNER"},"assignees":[{"id":8814129,"username":"OWNER","name":"Some User","state":"active","created_at":null,"avatar_url":"https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png","web_url":"https://gitlab.com/OWNER"}],"reviewers":[],"source_project_id":29316529,"target_project_id":29316529,"labels":"","label_details":null,"description":"Closes #1","draft":true,"work_in_progress":true,"milestone":null,"merge_when_pipeline_succeeds":false,"detailed_merge_status":"draft_status","merge_error":"","merged_by":null,"merged_at":null,"closed_by":null,"closed_at":null,"subscribed":true,"sha":"44eb489568f7cb1a5a730fce6b247cd3797172ca","merge_commit_sha":"","squash_commit_sha":"","user_notes_count":0,"changes_count":"1","should_remove_source_branch":false,"force_remove_source_branch":true,"allow_collaboration":false,"web_url":"https://gitlab.com/OWNER/REPO/-/merge_requests/4","references":{"short":"!4","relative":"!4","full":"OWNER/REPO!4"},"discussion_locked":false,"changes":null,"user":{"can_merge":true},"time_stats":{"human_time_estimate":"","human_total_time_spent":"","time_estimate":0,"total_time_spent":0},"squash":false,"pipeline":{"id":452959326,"iid":14,"project_id":29316529,"status":"success","source":"push","ref":"1-fake-issue-3","sha":"44eb489568f7cb1a5a730fce6b247cd3797172ca","web_url":"https://gitlab.com/OWNER/REPO/-/pipelines/452959326","updated_at":"2022-01-20T21:47:31.358Z","created_at":"2022-01-20T21:47:16.276Z"},"head_pipeline":{"id":452959326,"iid":14,"project_id":29316529,"status":"success","source":"push","ref":"1-fake-issue-3","sha":"44eb489568f7cb1a5a730fce6b247cd3797172ca","before_sha":"001eb421e586a3f07f90aea102c8b2d4068ab5b6","tag":false,"yaml_errors":"","user":{"id":8814129,"username":"OWNER","name":"Some User","state":"active","created_at":null,"avatar_url":"https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png","web_url":"https://gitlab.com/OWNER"},"updated_at":"2022-01-20T21:47:31.358Z","created_at":"2022-01-20T21:47:16.276Z","started_at":"2022-01-20T21:47:17.448Z","finished_at":"2022-01-20T21:47:31.35Z","committed_at":null,"duration":14,"queued_duration":1,"coverage":"","web_url":"https://gitlab.com/OWNER/REPO/-/pipelines/452959326","detailed_status":{"icon":"status_success","text":"Passed","label":"passed","group":"success","tooltip":"passed","has_details":true,"details_path":"/OWNER/REPO/-/pipelines/452959326","illustration":{"image":""},"favicon":"/assets/ci_favicons/favicon_status_success-8451333011eee8ce9f2ab25dc487fe24a8758c694827a582f17f42b0a90446a2.png"}},"diff_refs":{"base_sha":"001eb421e586a3f07f90aea102c8b2d4068ab5b6","head_sha":"44eb489568f7cb1a5a730fce6b247cd3797172ca","start_sha":"001eb421e586a3f07f90aea102c8b2d4068ab5b6"},"diverged_commits_count":0,"rebase_in_progress":false,"approvals_before_merge":0,"reference":"!4","first_contribution":true,"task_completion_status":{"count":0,"completed_count":0},"has_conflicts":false,"blocking_discussions_resolved":true,"overflow":false,"merge_status":"can_be_merged"} diff --git a/test/json_output_data/project/list/testdata/project_list-0.json b/test/json_output_data/project/list/testdata/project_list-0.json deleted file mode 100644 index aab22eb36..000000000 --- a/test/json_output_data/project/list/testdata/project_list-0.json +++ /dev/null @@ -1,195 +0,0 @@ -[ - { - "id": 36925508, - "description": "A GitLab CLI tool bringing GitLab to your command line", - "name": "cli", - "name_with_namespace": "Some User / cli", - "path": "gitlab-cli", - "path_with_namespace": "OWNER/gitlab-cli", - "created_at": "2022-06-10T15:58:21.579Z", - "default_branch": "main", - "tag_list": [], - "topics": [], - "ssh_url_to_repo": "git@gitlab.com:OWNER/gitlab-cli.git", - "http_url_to_repo": "https://gitlab.com/OWNER/gitlab-cli.git", - "web_url": "https://gitlab.com/OWNER/gitlab-cli", - "readme_url": "https://gitlab.com/OWNER/gitlab-cli/-/blob/main/README.md", - "forks_count": 0, - "avatar_url": "https://gitlab.com/uploads/-/system/project/avatar/36925508/cli-logo.png", - "star_count": 0, - "last_activity_at": "2024-02-13T23:14:22.104Z", - "namespace": { - "id": 11940376, - "name": "Some User", - "path": "OWNER", - "kind": "user", - "full_path": "OWNER", - "parent_id": null, - "avatar_url": "/uploads/-/system/user/avatar/8814129/avatar.png", - "web_url": "https://gitlab.com/OWNER" - }, - "container_registry_image_prefix": "registry.gitlab.com/OWNER/gitlab-cli", - "_links": { - "self": "https://gitlab.com/api/v4/projects/36925508", - "issues": "https://gitlab.com/api/v4/projects/36925508/issues", - "merge_requests": "https://gitlab.com/api/v4/projects/36925508/merge_requests", - "repo_branches": "https://gitlab.com/api/v4/projects/36925508/repository/branches", - "labels": "https://gitlab.com/api/v4/projects/36925508/labels", - "events": "https://gitlab.com/api/v4/projects/36925508/events", - "members": "https://gitlab.com/api/v4/projects/36925508/members", - "cluster_agents": "https://gitlab.com/api/v4/projects/36925508/cluster_agents" - }, - "packages_enabled": true, - "empty_repo": false, - "archived": false, - "visibility": "public", - "owner": { - "id": 8814129, - "username": "OWNER", - "name": "Some User", - "state": "active", - "locked": false, - "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", - "web_url": "https://gitlab.com/OWNER" - }, - "resolve_outdated_diff_discussions": false, - "container_expiration_policy": { - "cadence": "1d", - "enabled": false, - "keep_n": 10, - "older_than": "90d", - "name_regex": ".*", - "name_regex_keep": null, - "next_run_at": "2022-06-11T15:58:21.612Z" - }, - "repository_object_format": "sha1", - "issues_enabled": true, - "merge_requests_enabled": true, - "wiki_enabled": true, - "jobs_enabled": true, - "snippets_enabled": true, - "container_registry_enabled": true, - "service_desk_enabled": true, - "service_desk_address": "contact-project+OWNER-gitlab-cli-36925508-issue-@incoming.gitlab.com", - "can_create_merge_request_in": true, - "issues_access_level": "enabled", - "repository_access_level": "enabled", - "merge_requests_access_level": "enabled", - "forking_access_level": "enabled", - "wiki_access_level": "enabled", - "builds_access_level": "enabled", - "snippets_access_level": "enabled", - "pages_access_level": "enabled", - "analytics_access_level": "enabled", - "container_registry_access_level": "enabled", - "security_and_compliance_access_level": "private", - "releases_access_level": "enabled", - "environments_access_level": "enabled", - "feature_flags_access_level": "enabled", - "infrastructure_access_level": "enabled", - "monitor_access_level": "enabled", - "model_experiments_access_level": "enabled", - "model_registry_access_level": "enabled", - "emails_disabled": false, - "emails_enabled": true, - "shared_runners_enabled": true, - "lfs_enabled": true, - "creator_id": 8814129, - "forked_from_project": { - "id": 34675721, - "description": "A GitLab CLI tool bringing GitLab to your command line", - "name": "cli", - "name_with_namespace": "GitLab.org / cli", - "path": "cli", - "path_with_namespace": "gitlab-org/cli", - "created_at": "2022-03-21T18:49:22.691Z", - "default_branch": "main", - "tag_list": [], - "topics": [], - "ssh_url_to_repo": "git@gitlab.com:gitlab-org/cli.git", - "http_url_to_repo": "https://gitlab.com/gitlab-org/cli.git", - "web_url": "https://gitlab.com/gitlab-org/cli", - "readme_url": "https://gitlab.com/gitlab-org/cli/-/blob/main/README.md", - "forks_count": 159, - "avatar_url": "https://gitlab.com/uploads/-/system/project/avatar/34675721/cli-logo.png", - "star_count": 506, - "last_activity_at": "2024-02-13T21:07:22.636Z", - "namespace": { - "id": 9970, - "name": "GitLab.org", - "path": "gitlab-org", - "kind": "group", - "full_path": "gitlab-org", - "parent_id": null, - "avatar_url": "/uploads/-/system/group/avatar/9970/project_avatar.png", - "web_url": "https://gitlab.com/groups/gitlab-org" - } - }, - "mr_default_target_self": false, - "import_url": null, - "import_type": null, - "import_status": "finished", - "open_issues_count": 0, - "description_html": "

A GitLab CLI tool bringing GitLab to your command line

", - "updated_at": "2024-02-13T23:14:22.104Z", - "ci_default_git_depth": 20, - "ci_forward_deployment_enabled": true, - "ci_forward_deployment_rollback_allowed": true, - "ci_job_token_scope_enabled": false, - "ci_separated_caches": true, - "ci_allow_fork_pipelines_to_run_in_parent_project": true, - "build_git_strategy": "fetch", - "keep_latest_artifact": true, - "restrict_user_defined_variables": false, - "runners_token": "GR13489419rM8-WJybx8ggME3Uyf8", - "runner_token_expiration_interval": null, - "group_runners_enabled": true, - "auto_cancel_pending_pipelines": "enabled", - "build_timeout": 3600, - "auto_devops_enabled": false, - "auto_devops_deploy_strategy": "continuous", - "ci_config_path": "", - "public_jobs": true, - "shared_with_groups": [], - "only_allow_merge_if_pipeline_succeeds": false, - "allow_merge_on_skipped_pipeline": null, - "request_access_enabled": true, - "only_allow_merge_if_all_discussions_are_resolved": false, - "remove_source_branch_after_merge": true, - "printing_merge_request_link_enabled": true, - "merge_method": "merge", - "squash_option": "default_off", - "enforce_auth_checks_on_uploads": true, - "suggestion_commit_message": null, - "merge_commit_template": null, - "squash_commit_template": null, - "issue_branch_template": null, - "warn_about_potentially_unwanted_characters": true, - "autoclose_referenced_issues": true, - "approvals_before_merge": 0, - "mirror": false, - "external_authorization_classification_label": "", - "marked_for_deletion_at": null, - "marked_for_deletion_on": null, - "requirements_enabled": true, - "requirements_access_level": "enabled", - "security_and_compliance_enabled": true, - "compliance_frameworks": [], - "issues_template": null, - "merge_requests_template": null, - "ci_restrict_pipeline_cancellation_role": "developer", - "merge_pipelines_enabled": false, - "merge_trains_enabled": false, - "merge_trains_skip_train_allowed": false, - "only_allow_merge_if_all_status_checks_passed": false, - "allow_pipeline_trigger_approve_deployment": false, - "prevent_merge_without_jira_issue": false, - "permissions": { - "project_access": { - "access_level": 50, - "notification_level": 3 - }, - "group_access": null - } - } -] diff --git a/test/json_output_data/project/list/testdata/project_list-0.request b/test/json_output_data/project/list/testdata/project_list-0.request deleted file mode 100644 index 8c15d6b79..000000000 --- a/test/json_output_data/project/list/testdata/project_list-0.request +++ /dev/null @@ -1,4 +0,0 @@ -{ - "url": "/api/v4/projects?order_by=last_activity_at&owned=true&page=1&per_page=1", - "method": "GET" -} diff --git a/test/json_output_data/project/list/testdata/project_list.result b/test/json_output_data/project/list/testdata/project_list.result deleted file mode 100644 index e44285a8f..000000000 --- a/test/json_output_data/project/list/testdata/project_list.result +++ /dev/null @@ -1 +0,0 @@ -[{"id":36925508,"description":"A GitLab CLI tool bringing GitLab to your command line","default_branch":"main","public":false,"visibility":"public","ssh_url_to_repo":"git@gitlab.com:OWNER/gitlab-cli.git","http_url_to_repo":"https://gitlab.com/OWNER/gitlab-cli.git","web_url":"https://gitlab.com/OWNER/gitlab-cli","readme_url":"https://gitlab.com/OWNER/gitlab-cli/-/blob/main/README.md","tag_list":[],"topics":[],"owner":{"id":8814129,"username":"OWNER","email":"","name":"Some User","state":"active","web_url":"https://gitlab.com/OWNER","created_at":null,"bio":"","bot":false,"location":"","public_email":"","skype":"","linkedin":"","twitter":"","website_url":"","organization":"","job_title":"","extern_uid":"","provider":"","theme_id":0,"last_activity_on":null,"color_scheme_id":0,"is_admin":false,"avatar_url":"https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png","can_create_group":false,"can_create_project":false,"projects_limit":0,"current_sign_in_at":null,"current_sign_in_ip":null,"last_sign_in_at":null,"last_sign_in_ip":null,"confirmed_at":null,"two_factor_enabled":false,"note":"","identities":null,"external":false,"private_profile":false,"shared_runners_minutes_limit":0,"extra_shared_runners_minutes_limit":0,"using_license_seat":false,"custom_attributes":null,"namespace_id":0},"name":"cli","name_with_namespace":"Some User / cli","path":"gitlab-cli","path_with_namespace":"OWNER/gitlab-cli","issues_enabled":true,"open_issues_count":0,"merge_requests_enabled":true,"approvals_before_merge":0,"jobs_enabled":true,"wiki_enabled":true,"snippets_enabled":true,"resolve_outdated_diff_discussions":false,"container_expiration_policy":{"cadence":"1d","keep_n":10,"older_than":"90d","name_regex":".*","name_regex_delete":"","name_regex_keep":"","enabled":false,"next_run_at":"2022-06-11T15:58:21.612Z"},"container_registry_enabled":true,"container_registry_access_level":"enabled","container_registry_image_prefix":"registry.gitlab.com/OWNER/gitlab-cli","created_at":"2022-06-10T15:58:21.579Z","last_activity_at":"2024-02-13T23:14:22.104Z","creator_id":8814129,"namespace":{"id":11940376,"name":"Some User","path":"OWNER","kind":"user","full_path":"OWNER","parent_id":0,"avatar_url":"/uploads/-/system/user/avatar/8814129/avatar.png","web_url":"https://gitlab.com/OWNER"},"permissions":{"project_access":{"access_level":50,"notification_level":"global"},"group_access":null},"marked_for_deletion_at":null,"empty_repo":false,"archived":false,"avatar_url":"https://gitlab.com/uploads/-/system/project/avatar/36925508/cli-logo.png","license_url":"","license":null,"shared_runners_enabled":true,"group_runners_enabled":true,"runner_token_expiration_interval":0,"forks_count":0,"star_count":0,"runners_token":"GR13489419rM8-WJybx8ggME3Uyf8","allow_merge_on_skipped_pipeline":false,"only_allow_merge_if_pipeline_succeeds":false,"only_allow_merge_if_all_discussions_are_resolved":false,"remove_source_branch_after_merge":true,"printing_merge_request_link_enabled":true,"lfs_enabled":true,"repository_storage":"","request_access_enabled":true,"merge_method":"merge","can_create_merge_request_in":true,"forked_from_project":{"id":34675721,"name":"cli","name_with_namespace":"GitLab.org / cli","path":"cli","path_with_namespace":"gitlab-org/cli","http_url_to_repo":"https://gitlab.com/gitlab-org/cli.git","web_url":"https://gitlab.com/gitlab-org/cli","repository_storage":""},"mirror":false,"mirror_user_id":0,"mirror_trigger_builds":false,"only_mirror_protected_branches":false,"mirror_overwrites_diverged_branches":false,"packages_enabled":true,"service_desk_enabled":true,"service_desk_address":"contact-project+OWNER-gitlab-cli-36925508-issue-@incoming.gitlab.com","issues_access_level":"enabled","releases_access_level":"enabled","repository_access_level":"enabled","merge_requests_access_level":"enabled","forking_access_level":"enabled","wiki_access_level":"enabled","builds_access_level":"enabled","snippets_access_level":"enabled","pages_access_level":"enabled","operations_access_level":"","analytics_access_level":"enabled","environments_access_level":"enabled","feature_flags_access_level":"enabled","infrastructure_access_level":"enabled","monitor_access_level":"enabled","autoclose_referenced_issues":true,"suggestion_commit_message":"","squash_option":"default_off","enforce_auth_checks_on_uploads":true,"shared_with_groups":[],"statistics":null,"_links":{"self":"https://gitlab.com/api/v4/projects/36925508","issues":"https://gitlab.com/api/v4/projects/36925508/issues","merge_requests":"https://gitlab.com/api/v4/projects/36925508/merge_requests","repo_branches":"https://gitlab.com/api/v4/projects/36925508/repository/branches","labels":"https://gitlab.com/api/v4/projects/36925508/labels","events":"https://gitlab.com/api/v4/projects/36925508/events","members":"https://gitlab.com/api/v4/projects/36925508/members","cluster_agents":"https://gitlab.com/api/v4/projects/36925508/cluster_agents"},"import_url":"","import_type":"","import_status":"finished","import_error":"","ci_default_git_depth":20,"ci_forward_deployment_enabled":true,"ci_separated_caches":true,"ci_job_token_scope_enabled":false,"ci_opt_in_jwt":false,"ci_allow_fork_pipelines_to_run_in_parent_project":true,"public_jobs":true,"build_timeout":3600,"auto_cancel_pending_pipelines":"enabled","ci_config_path":"","custom_attributes":null,"compliance_frameworks":[],"build_coverage_regex":"","issues_template":"","merge_requests_template":"","issue_branch_template":"","keep_latest_artifact":true,"merge_pipelines_enabled":false,"merge_trains_enabled":false,"restrict_user_defined_variables":false,"merge_commit_template":"","squash_commit_template":"","auto_devops_deploy_strategy":"continuous","auto_devops_enabled":false,"build_git_strategy":"fetch","emails_enabled":true,"external_authorization_classification_label":"","requirements_enabled":true,"requirements_access_level":"enabled","security_and_compliance_enabled":true,"security_and_compliance_access_level":"private","mr_default_target_self":false,"emails_disabled":false,"public_builds":false}] diff --git a/test/json_output_data/project/view/testdata/project_view-0.json b/test/json_output_data/project/view/testdata/project_view-0.json deleted file mode 100644 index 20d0fc8b1..000000000 --- a/test/json_output_data/project/view/testdata/project_view-0.json +++ /dev/null @@ -1,177 +0,0 @@ -{ - "id": 29316529, - "description": "", - "name": "REPO", - "name_with_namespace": "Some User / REPO", - "path": "REPO", - "path_with_namespace": "OWNER/REPO", - "created_at": "2021-09-02T13:38:42.806Z", - "default_branch": "main", - "tag_list": [], - "topics": [], - "ssh_url_to_repo": "git@gitlab.com:OWNER/REPO.git", - "http_url_to_repo": "https://gitlab.com/OWNER/REPO.git", - "web_url": "https://gitlab.com/OWNER/REPO", - "readme_url": "https://gitlab.com/OWNER/REPO/-/blob/main/README.md", - "forks_count": 0, - "license_url": null, - "license": null, - "avatar_url": null, - "star_count": 0, - "last_activity_at": "2022-01-20T21:11:56.564Z", - "namespace": { - "id": 11940376, - "name": "Some User", - "path": "OWNER", - "kind": "user", - "full_path": "OWNER", - "parent_id": null, - "avatar_url": "/uploads/-/system/user/avatar/8814129/avatar.png", - "web_url": "https://gitlab.com/OWNER" - }, - "container_registry_image_prefix": "registry.gitlab.com/OWNER/REPO", - "_links": { - "self": "https://gitlab.com/api/v4/projects/29316529", - "issues": "https://gitlab.com/api/v4/projects/29316529/issues", - "merge_requests": "https://gitlab.com/api/v4/projects/29316529/merge_requests", - "repo_branches": "https://gitlab.com/api/v4/projects/29316529/repository/branches", - "labels": "https://gitlab.com/api/v4/projects/29316529/labels", - "events": "https://gitlab.com/api/v4/projects/29316529/events", - "members": "https://gitlab.com/api/v4/projects/29316529/members", - "cluster_agents": "https://gitlab.com/api/v4/projects/29316529/cluster_agents" - }, - "packages_enabled": true, - "empty_repo": false, - "archived": false, - "visibility": "public", - "owner": { - "id": 8814129, - "username": "OWNER", - "name": "Some User", - "state": "active", - "locked": false, - "avatar_url": "https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png", - "web_url": "https://gitlab.com/OWNER" - }, - "resolve_outdated_diff_discussions": false, - "container_expiration_policy": { - "cadence": "1d", - "enabled": false, - "keep_n": 10, - "older_than": "90d", - "name_regex": ".*", - "name_regex_keep": null, - "next_run_at": "2021-09-03T13:38:42.834Z" - }, - "repository_object_format": "sha1", - "issues_enabled": true, - "merge_requests_enabled": true, - "wiki_enabled": true, - "jobs_enabled": true, - "snippets_enabled": true, - "container_registry_enabled": true, - "service_desk_enabled": true, - "service_desk_address": "contact-project+OWNER-REPO-29316529-issue-@incoming.gitlab.com", - "can_create_merge_request_in": true, - "issues_access_level": "enabled", - "repository_access_level": "enabled", - "merge_requests_access_level": "enabled", - "forking_access_level": "enabled", - "wiki_access_level": "enabled", - "builds_access_level": "enabled", - "snippets_access_level": "enabled", - "pages_access_level": "enabled", - "analytics_access_level": "enabled", - "container_registry_access_level": "enabled", - "security_and_compliance_access_level": "private", - "releases_access_level": "enabled", - "environments_access_level": "enabled", - "feature_flags_access_level": "enabled", - "infrastructure_access_level": "enabled", - "monitor_access_level": "enabled", - "model_experiments_access_level": "enabled", - "model_registry_access_level": "enabled", - "emails_disabled": false, - "emails_enabled": true, - "shared_runners_enabled": true, - "lfs_enabled": true, - "creator_id": 8814129, - "import_url": null, - "import_type": null, - "import_status": "none", - "import_error": null, - "open_issues_count": 1, - "description_html": "", - "updated_at": "2024-01-19T18:08:30.859Z", - "ci_default_git_depth": 50, - "ci_forward_deployment_enabled": true, - "ci_forward_deployment_rollback_allowed": true, - "ci_job_token_scope_enabled": false, - "ci_separated_caches": true, - "ci_allow_fork_pipelines_to_run_in_parent_project": true, - "build_git_strategy": "fetch", - "keep_latest_artifact": true, - "restrict_user_defined_variables": false, - "runners_token": "GR134894151j85TmuYJpzvNBypfaw", - "runner_token_expiration_interval": null, - "group_runners_enabled": true, - "auto_cancel_pending_pipelines": "enabled", - "build_timeout": 3600, - "auto_devops_enabled": false, - "auto_devops_deploy_strategy": "continuous", - "ci_config_path": "", - "public_jobs": true, - "shared_with_groups": [], - "only_allow_merge_if_pipeline_succeeds": false, - "allow_merge_on_skipped_pipeline": false, - "request_access_enabled": true, - "only_allow_merge_if_all_discussions_are_resolved": false, - "remove_source_branch_after_merge": true, - "printing_merge_request_link_enabled": true, - "merge_method": "merge", - "squash_option": "default_on", - "enforce_auth_checks_on_uploads": true, - "suggestion_commit_message": "", - "merge_commit_template": "", - "squash_commit_template": "", - "issue_branch_template": null, - "statistics": { - "commit_count": 5, - "storage_size": 88110, - "repository_size": 6782, - "wiki_size": 0, - "lfs_objects_size": 0, - "job_artifacts_size": 81328, - "pipeline_artifacts_size": 0, - "packages_size": 0, - "snippets_size": 0, - "uploads_size": 0 - }, - "warn_about_potentially_unwanted_characters": true, - "autoclose_referenced_issues": true, - "approvals_before_merge": 0, - "mirror": false, - "external_authorization_classification_label": "", - "marked_for_deletion_at": null, - "marked_for_deletion_on": null, - "requirements_enabled": true, - "requirements_access_level": "enabled", - "security_and_compliance_enabled": true, - "compliance_frameworks": [], - "issues_template": null, - "merge_requests_template": "", - "ci_restrict_pipeline_cancellation_role": "developer", - "merge_pipelines_enabled": false, - "merge_trains_enabled": false, - "merge_trains_skip_train_allowed": false, - "only_allow_merge_if_all_status_checks_passed": false, - "allow_pipeline_trigger_approve_deployment": false, - "prevent_merge_without_jira_issue": false, - "permissions": { - "project_access": { - "access_level": 50, - "notification_level": 3 - }, - "group_access": null - } -} diff --git a/test/json_output_data/project/view/testdata/project_view-0.request b/test/json_output_data/project/view/testdata/project_view-0.request deleted file mode 100644 index a1a0c54c2..000000000 --- a/test/json_output_data/project/view/testdata/project_view-0.request +++ /dev/null @@ -1,4 +0,0 @@ -{ - "url": "/api/v4/projects/OWNER%2FREPO?license=true&statistics=true&with_custom_attributes=true", - "method": "GET" -} diff --git a/test/json_output_data/project/view/testdata/project_view.result b/test/json_output_data/project/view/testdata/project_view.result deleted file mode 100644 index 927f4581f..000000000 --- a/test/json_output_data/project/view/testdata/project_view.result +++ /dev/null @@ -1 +0,0 @@ -{"id":29316529,"description":"","default_branch":"main","public":false,"visibility":"public","ssh_url_to_repo":"git@gitlab.com:OWNER/REPO.git","http_url_to_repo":"https://gitlab.com/OWNER/REPO.git","web_url":"https://gitlab.com/OWNER/REPO","readme_url":"https://gitlab.com/OWNER/REPO/-/blob/main/README.md","tag_list":[],"topics":[],"owner":{"id":8814129,"username":"OWNER","email":"","name":"Some User","state":"active","web_url":"https://gitlab.com/OWNER","created_at":null,"bio":"","bot":false,"location":"","public_email":"","skype":"","linkedin":"","twitter":"","website_url":"","organization":"","job_title":"","extern_uid":"","provider":"","theme_id":0,"last_activity_on":null,"color_scheme_id":0,"is_admin":false,"avatar_url":"https://gitlab.com/uploads/-/system/user/avatar/8814129/avatar.png","can_create_group":false,"can_create_project":false,"projects_limit":0,"current_sign_in_at":null,"current_sign_in_ip":null,"last_sign_in_at":null,"last_sign_in_ip":null,"confirmed_at":null,"two_factor_enabled":false,"note":"","identities":null,"external":false,"private_profile":false,"shared_runners_minutes_limit":0,"extra_shared_runners_minutes_limit":0,"using_license_seat":false,"custom_attributes":null,"namespace_id":0},"name":"REPO","name_with_namespace":"Some User / REPO","path":"REPO","path_with_namespace":"OWNER/REPO","issues_enabled":true,"open_issues_count":1,"merge_requests_enabled":true,"approvals_before_merge":0,"jobs_enabled":true,"wiki_enabled":true,"snippets_enabled":true,"resolve_outdated_diff_discussions":false,"container_expiration_policy":{"cadence":"1d","keep_n":10,"older_than":"90d","name_regex":".*","name_regex_delete":"","name_regex_keep":"","enabled":false,"next_run_at":"2021-09-03T13:38:42.834Z"},"container_registry_enabled":true,"container_registry_access_level":"enabled","container_registry_image_prefix":"registry.gitlab.com/OWNER/REPO","created_at":"2021-09-02T13:38:42.806Z","last_activity_at":"2022-01-20T21:11:56.564Z","creator_id":8814129,"namespace":{"id":11940376,"name":"Some User","path":"OWNER","kind":"user","full_path":"OWNER","parent_id":0,"avatar_url":"/uploads/-/system/user/avatar/8814129/avatar.png","web_url":"https://gitlab.com/OWNER"},"permissions":{"project_access":{"access_level":50,"notification_level":"global"},"group_access":null},"marked_for_deletion_at":null,"empty_repo":false,"archived":false,"avatar_url":"","license_url":"","license":null,"shared_runners_enabled":true,"group_runners_enabled":true,"runner_token_expiration_interval":0,"forks_count":0,"star_count":0,"runners_token":"GR134894151j85TmuYJpzvNBypfaw","allow_merge_on_skipped_pipeline":false,"only_allow_merge_if_pipeline_succeeds":false,"only_allow_merge_if_all_discussions_are_resolved":false,"remove_source_branch_after_merge":true,"printing_merge_request_link_enabled":true,"lfs_enabled":true,"repository_storage":"","request_access_enabled":true,"merge_method":"merge","can_create_merge_request_in":true,"forked_from_project":null,"mirror":false,"mirror_user_id":0,"mirror_trigger_builds":false,"only_mirror_protected_branches":false,"mirror_overwrites_diverged_branches":false,"packages_enabled":true,"service_desk_enabled":true,"service_desk_address":"contact-project+OWNER-REPO-29316529-issue-@incoming.gitlab.com","issues_access_level":"enabled","releases_access_level":"enabled","repository_access_level":"enabled","merge_requests_access_level":"enabled","forking_access_level":"enabled","wiki_access_level":"enabled","builds_access_level":"enabled","snippets_access_level":"enabled","pages_access_level":"enabled","operations_access_level":"","analytics_access_level":"enabled","environments_access_level":"enabled","feature_flags_access_level":"enabled","infrastructure_access_level":"enabled","monitor_access_level":"enabled","autoclose_referenced_issues":true,"suggestion_commit_message":"","squash_option":"default_on","enforce_auth_checks_on_uploads":true,"shared_with_groups":[],"statistics":{"commit_count":5,"storage_size":88110,"repository_size":6782,"wiki_size":0,"lfs_objects_size":0,"job_artifacts_size":81328,"pipeline_artifacts_size":0,"packages_size":0,"snippets_size":0,"uploads_size":0},"_links":{"self":"https://gitlab.com/api/v4/projects/29316529","issues":"https://gitlab.com/api/v4/projects/29316529/issues","merge_requests":"https://gitlab.com/api/v4/projects/29316529/merge_requests","repo_branches":"https://gitlab.com/api/v4/projects/29316529/repository/branches","labels":"https://gitlab.com/api/v4/projects/29316529/labels","events":"https://gitlab.com/api/v4/projects/29316529/events","members":"https://gitlab.com/api/v4/projects/29316529/members","cluster_agents":"https://gitlab.com/api/v4/projects/29316529/cluster_agents"},"import_url":"","import_type":"","import_status":"none","import_error":"","ci_default_git_depth":50,"ci_forward_deployment_enabled":true,"ci_separated_caches":true,"ci_job_token_scope_enabled":false,"ci_opt_in_jwt":false,"ci_allow_fork_pipelines_to_run_in_parent_project":true,"public_jobs":true,"build_timeout":3600,"auto_cancel_pending_pipelines":"enabled","ci_config_path":"","custom_attributes":null,"compliance_frameworks":[],"build_coverage_regex":"","issues_template":"","merge_requests_template":"","issue_branch_template":"","keep_latest_artifact":true,"merge_pipelines_enabled":false,"merge_trains_enabled":false,"restrict_user_defined_variables":false,"merge_commit_template":"","squash_commit_template":"","auto_devops_deploy_strategy":"continuous","auto_devops_enabled":false,"build_git_strategy":"fetch","emails_enabled":true,"external_authorization_classification_label":"","requirements_enabled":true,"requirements_access_level":"enabled","security_and_compliance_enabled":true,"security_and_compliance_access_level":"private","mr_default_target_self":false,"emails_disabled":false,"public_builds":false} diff --git a/test/json_output_data/variable/get/testdata/variable_get-0.json b/test/json_output_data/variable/get/testdata/variable_get-0.json deleted file mode 100644 index 5f46d9349..000000000 --- a/test/json_output_data/variable/get/testdata/variable_get-0.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "variable_type": "env_var", - "key": "PROJECT_VAR", - "value": "project", - "protected": false, - "masked": false, - "raw": false, - "environment_scope": "*", - "description": null -} diff --git a/test/json_output_data/variable/get/testdata/variable_get-0.request b/test/json_output_data/variable/get/testdata/variable_get-0.request deleted file mode 100644 index e7d6712d2..000000000 --- a/test/json_output_data/variable/get/testdata/variable_get-0.request +++ /dev/null @@ -1,4 +0,0 @@ -{ - "url": "/api/v4/projects/OWNER%2FREPO/variables/PROJECT_VAR?filter%5Benvironment_scope%5D=%2A", - "method": "GET" -} diff --git a/test/json_output_data/variable/get/testdata/variable_get.result b/test/json_output_data/variable/get/testdata/variable_get.result deleted file mode 100644 index 836245f17..000000000 --- a/test/json_output_data/variable/get/testdata/variable_get.result +++ /dev/null @@ -1 +0,0 @@ -{"key":"PROJECT_VAR","value":"project","variable_type":"env_var","protected":false,"masked":false,"raw":false,"environment_scope":"*"} diff --git a/test/json_output_data/variable/list/testdata/variable_list-0.json b/test/json_output_data/variable/list/testdata/variable_list-0.json deleted file mode 100644 index 6c3ccb745..000000000 --- a/test/json_output_data/variable/list/testdata/variable_list-0.json +++ /dev/null @@ -1,12 +0,0 @@ -[ - { - "variable_type": "env_var", - "key": "PROJECT_VAR", - "value": "project", - "protected": false, - "masked": false, - "raw": false, - "environment_scope": "*", - "description": null - } -] diff --git a/test/json_output_data/variable/list/testdata/variable_list-0.request b/test/json_output_data/variable/list/testdata/variable_list-0.request deleted file mode 100644 index e82d25ca2..000000000 --- a/test/json_output_data/variable/list/testdata/variable_list-0.request +++ /dev/null @@ -1,4 +0,0 @@ -{ - "url": "/api/v4/projects/OWNER%2FREPO/variables", - "method": "GET" -} diff --git a/test/json_output_data/variable/list/testdata/variable_list.result b/test/json_output_data/variable/list/testdata/variable_list.result deleted file mode 100644 index 900d5c6d9..000000000 --- a/test/json_output_data/variable/list/testdata/variable_list.result +++ /dev/null @@ -1 +0,0 @@ -[{"key":"PROJECT_VAR","value":"project","variable_type":"env_var","protected":false,"masked":false,"raw":false,"environment_scope":"*"}] -- GitLab From bab7ffe59702bef942070bb8a2fd3916cf87b1e8 Mon Sep 17 00:00:00 2001 From: Jay McCure Date: Wed, 21 Feb 2024 18:12:22 +1000 Subject: [PATCH 15/15] test: fix ci get test --- commands/ci/get/get_test.go | 51 +++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/commands/ci/get/get_test.go b/commands/ci/get/get_test.go index 567b4e7fc..af0ad524f 100644 --- a/commands/ci/get/get_test.go +++ b/commands/ci/get/get_test.go @@ -1,7 +1,6 @@ package status import ( - "fmt" "net/http" "os" "testing" @@ -27,8 +26,8 @@ func runCommand(rt http.RoundTripper, isTTY bool, args string) (*test.CmdOut, er } const ( - FILE_BODY = 1 - INLINE_BODY = 2 + FileBody = 1 + InlineBody = 2 ) func TestCIGet(t *testing.T) { @@ -70,14 +69,14 @@ func TestCIGet(t *testing.T) { "started_at": "2023-10-10T00:00:00Z", "updated_at": "2023-10-10T00:00:00Z" }`, - INLINE_BODY, + InlineBody, }, { http.MethodGet, "/api/v4/projects/OWNER%2FREPO/pipelines/123/jobs?per_page=100", http.StatusOK, `[]`, - INLINE_BODY, + InlineBody, }, }, expectedOut: `# Pipeline: @@ -120,14 +119,14 @@ updated: 2023-10-10 00:00:00 +0000 UTC "started_at": "2023-10-10T00:00:00Z", "updated_at": "2023-10-10T00:00:00Z" }`, - INLINE_BODY, + InlineBody, }, { http.MethodGet, "/api/v4/projects/OWNER%2FREPO/pipelines/123/jobs?per_page=100", http.StatusOK, `[]`, - INLINE_BODY, + InlineBody, }, { http.MethodGet, @@ -138,7 +137,7 @@ updated: 2023-10-10 00:00:00 +0000 UTC "id": 123 } }`, - INLINE_BODY, + InlineBody, }, }, expectedOut: `# Pipeline: @@ -181,7 +180,7 @@ updated: 2023-10-10 00:00:00 +0000 UTC "started_at": "2023-10-10T00:00:00Z", "updated_at": "2023-10-10T00:00:00Z" }`, - INLINE_BODY, + InlineBody, }, { http.MethodGet, @@ -192,7 +191,7 @@ updated: 2023-10-10 00:00:00 +0000 UTC "name": "publish", "status": "failed" }]`, - INLINE_BODY, + InlineBody, }, }, expectedOut: `# Pipeline: @@ -236,7 +235,7 @@ publish: failed "started_at": "2023-10-10T00:00:00Z", "updated_at": "2023-10-10T00:00:00Z" }`, - INLINE_BODY, + InlineBody, }, { http.MethodGet, @@ -248,7 +247,7 @@ publish: failed "status": "failed", "failure_reason": "bad timing" }]`, - INLINE_BODY, + InlineBody, }, }, expectedOut: `# Pipeline: @@ -294,14 +293,14 @@ ID Name Status Duration Failure reason "started_at": "2023-10-10T00:00:00Z", "updated_at": "2023-10-10T00:00:00Z" }`, - INLINE_BODY, + InlineBody, }, { http.MethodGet, "/api/v4/projects/OWNER%2FREPO/pipelines/123/jobs?per_page=100", http.StatusOK, `[]`, - INLINE_BODY, + InlineBody, }, { http.MethodGet, @@ -312,7 +311,7 @@ ID Name Status Duration Failure reason "variable_type": "env_var", "value": "true" }]`, - INLINE_BODY, + InlineBody, }, }, expectedOut: `# Pipeline: @@ -359,21 +358,21 @@ RUN_NIGHTLY_BUILD: true "started_at": "2023-10-10T00:00:00Z", "updated_at": "2023-10-10T00:00:00Z" }`, - INLINE_BODY, + InlineBody, }, { http.MethodGet, "/api/v4/projects/OWNER%2FREPO/pipelines/123/jobs?per_page=100", http.StatusOK, `[]`, - INLINE_BODY, + InlineBody, }, { http.MethodGet, "/api/v4/projects/5/pipelines/123/variables", http.StatusOK, "[]", - INLINE_BODY, + InlineBody, }, }, expectedOut: `# Pipeline: @@ -397,25 +396,25 @@ No variables found in pipeline. }, { name: "when getting JSON for pipeline", - args: "-p 452959326 -F json", + args: "-p 452959326 -F json -b main", httpMocks: []httpMock{ { http.MethodGet, "/api/v4/projects/OWNER%2FREPO/pipelines/452959326", http.StatusOK, "testdata/ci_get-0.json", - FILE_BODY, + FileBody, }, { http.MethodGet, "/api/v4/projects/OWNER%2FREPO/pipelines/452959326/jobs?per_page=100", http.StatusOK, "testdata/ci_get-1.json", - FILE_BODY, + FileBody, }, }, expectedOut: "testdata/ci_get.result", - expectedOutType: FILE_BODY, + expectedOutType: FileBody, }, } @@ -428,7 +427,7 @@ No variables found in pipeline. for _, mock := range tc.httpMocks { var body string - if mock.bodyType == FILE_BODY { + if mock.bodyType == FileBody { bodyBytes, _ := os.ReadFile(mock.body) body = string(bodyBytes) } else { @@ -442,16 +441,14 @@ No variables found in pipeline. var expectedOut string var expectedOutBytes []byte - fmt.Printf("++>> %s\n", output.String()) - if tc.expectedOutType == FILE_BODY { + if tc.expectedOutType == FileBody { expectedOutBytes, err = os.ReadFile(tc.expectedOut) expectedOut = string(expectedOutBytes) require.Nil(t, err) } else { expectedOut = tc.expectedOut } - // err = os.WriteFile("/tmp/received", []byte(output.String()), 0o644) - // require.Nil(t, err) + assert.Equal(t, expectedOut, output.String()) assert.Empty(t, output.Stderr()) }) -- GitLab