Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AST-36690 | cleanup integration test #671

Merged
merged 9 commits into from
Mar 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions internal/commands/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,20 +545,22 @@ func toProjectViews(models []wrappers.ProjectResponseModel) []projectView {

func toProjectView(model wrappers.ProjectResponseModel) projectView { //nolint:gocritic
return projectView{
ID: model.ID,
Name: model.Name,
CreatedAt: model.CreatedAt,
UpdatedAt: model.UpdatedAt,
Tags: model.Tags,
Groups: model.Groups,
ID: model.ID,
Name: model.Name,
CreatedAt: model.CreatedAt,
UpdatedAt: model.UpdatedAt,
Tags: model.Tags,
Groups: model.Groups,
ApplicationIds: model.ApplicationIds,
}
}

type projectView struct {
ID string `format:"name:Project ID"`
Name string
CreatedAt time.Time `format:"name:Created at;time:01-02-06 15:04:05"`
UpdatedAt time.Time `format:"name:Updated at;time:01-02-06 15:04:05"`
Tags map[string]string
Groups []string
ID string `format:"name:Project ID"`
Name string
CreatedAt time.Time `format:"name:Created at;time:01-02-06 15:04:05"`
UpdatedAt time.Time `format:"name:Updated at;time:01-02-06 15:04:05"`
Tags map[string]string
Groups []string
ApplicationIds []string
}
8 changes: 6 additions & 2 deletions test/integration/project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,17 @@ func TestProjectCreate_ApplicationDoesntExist_FailAndReturnErrorMessage(t *testi

func TestProjectCreate_ApplicationExists_CreateProjectSuccessfully(t *testing.T) {

err, _ := executeCommand(
err, outBuffer := executeCommand(
t, "project", "create", flag(params.FormatFlag),
printer.FormatJSON, flag(params.ProjectName), projectNameRandom,
flag(params.ApplicationName), "my-application",
)

createdProject := wrappers.ProjectResponseModel{}
OrShamirCM marked this conversation as resolved.
Show resolved Hide resolved
unmarshall(t, outBuffer, &createdProject, "Reading project create response JSON should pass")
defer deleteProject(t, createdProject.ID)
assert.NilError(t, err)
OrShamirCM marked this conversation as resolved.
Show resolved Hide resolved
assert.Assert(t, createdProject.ID != "", "Project ID should not be empty")
assert.Assert(t, len(createdProject.ApplicationIds) == 1, "The project must be connected to the application")
}

func TestCreateWithInvalidGroup(t *testing.T) {
Expand Down
8 changes: 5 additions & 3 deletions test/integration/scan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,12 @@ func TestScanCreate_ExistingApplicationAndNotExistingProject_CreatingNewProjectA
flag(params.SourcesFlag), ".",
flag(params.ScanTypes), "sast",
flag(params.BranchFlag), "dummy_branch",
flag(params.ScanInfoFormatFlag), printer.FormatJSON,
}

err, _ := executeCommand(t, args...)
assert.NilError(t, err)
scanID, projectID := executeCreateScan(t, args)
defer deleteProject(t, projectID)
assert.Assert(t, scanID != "", "Scan ID should not be empty")
assert.Assert(t, projectID != "", "Project ID should not be empty")
}

func TestScanCreate_ApplicationDoesntExist_FailScanWithError(t *testing.T) {
Expand Down
Loading