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

Initial release #1

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open

Initial release #1

wants to merge 29 commits into from

Conversation

CameronSWilliamson
Copy link
Contributor

Adding the following functions:

  • Get-YTIssue
  • Get-YTProject
  • Invoke-YTRestMethod
  • New-YTIssue
  • New-YTProject
  • New-YTSession

It 'returns one project' {
GivenProject -ShortName 'GYTP1' -Name 'Get-YTProject Test Project' -Leader 'admin'
WhenGettingProject -ProjectShortName 'DEMO'
ThenProjectsReturned -GreaterThanEqual 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would combine the two ThenProject* functions into a single ThenReturns function:

ThenReturns -Count 2
ThenReturns -ProjectWithShortName 'DEMO'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use GreaterThanEqual. Use an exact count. If you use greater than or equal to, if the API returns more than expected, tests will still pass.

It 'return all projects' {
WhenGettingProject
ThenProjectsReturned -GreaterThanEqual 2
ThenProjectWithShortName -ShortName 'DEMO'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assert both projects that get returned.

Tests/Invoke-YTRestMethod.Tests.ps1 Show resolved Hide resolved
}

It 'should create a new issue' {
GivenSummary 'First YTAutomation Issue'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove tall these Given functions. Given functions should, in general, be used to setup the state of the system. These are better as parameters on WhenCreatingIssue.

WhenCreatingIssue -WithSummary '' -WithDescription '' -InProject ''

GivenDescription 'This is the first issue created by the YouTrackAutomation module.'
GivenProjectShortName 'NYTI'
WhenCreatingIssue
ThenIssue
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add parameter users have to pass to assert the issue:

ThenIssue -Created -WithSummary '' -WithDescription '' -InProject ''

ThenIssue should make a call to YouTrack to get the issue.


# The project that the issue will be created in. This should be the short name of the project.
[Parameter(Mandatory)]
[String] $Project,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to make as few web requests as possible, so either change this to ProjectID or allow users to pass a project object, short name, or ID. For the second object, change its type to Object then create a Resolve-YTProject function that handles that:

if ($Project | Get-Member -Name 'id')
{
    return $Project.id
}

if ($Project -is [int] -or $Project -match '^\d+$' )
{
    return Get-YTProject -Session $Session -ID $Project
}

if ($Project -is [String])
{
    return Get-YTProject -Session $Session -ShortName $Project
}

Write-Error "Failed to resolve project ""${Project}"": expected an object with an `id` property, an integer ID, or a project short name."


if ($Template)
{
$fields += "&template=$Template"
Copy link
Member

@splatteredbits splatteredbits Aug 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Encode $Template.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bump.

@@ -18,7 +18,7 @@
RootModule = 'YouTrackAutomation.psm1'

# Version number of this module.
ModuleVersion = '0.0.0'
ModuleVersion = '0.1.0'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.0.0.

@@ -73,6 +74,10 @@ Build:
- PublishPowerShellModule:
Path: YouTrackAutomation

- PowerShell:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Call reset.ps1 instead.

But consider removing? Do we really need to clean up on the build server? The VM we're using is going to get reaped by AppVeyor...

init.ps1 Outdated
Invoke-WebRequest -Uri "https://download-cdn.jetbrains.com/charisma/youtrack-${YouTrackVersion}.zip" -OutFile $archivePath
}

$dataArchivePath = Join-Path -Path $PSScriptRoot -ChildPath 'ytconfig.zip'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check these files into source loose, not as a ZIP file. If/when we ever need to update them, we'll have to unzip this file, update them, then zip the file back up again. It makes it hard to see what changed with the config and why.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, we just commit the files we change/care about to get YT running/working.

init.ps1 Outdated
@@ -6,6 +7,9 @@ Gets your computer ready to develop the YouTrackAutomation module.
The init.ps1 script makes the configuraion changes necessary to get your computer ready to develop for the
YouTrackAutomation module. It:

* Installs YouTrack to the current folder from an pre-configured YouTrack instance.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/an/a/

@@ -6,6 +7,9 @@ Gets your computer ready to develop the YouTrackAutomation module.
The init.ps1 script makes the configuraion changes necessary to get your computer ready to develop for the
YouTrackAutomation module. It:

* Installs YouTrack to the current folder from an pre-configured YouTrack instance.
* Configures the YouTrack instance to use the default port of 8080 and listen on 'localhost'.
* Sets up the default user account with the username 'admin' and password 'admin'.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any way to generate a random password? Typically, I'll save the password to a .password file that gets ignored by source control.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't look to me like that is possible. I'll keep looking though.

Gets an issue from YouTrack.

.DESCRIPTION
The `Get-YTIssue` function gets an issue from YouTrack using the issue ID or issue key. The function returns the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bump.

$fields += ",$($AdditionalField -join ',')"
}

$fields = [Uri]::EscapeUriString($fields)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be [Uri]::EscapeDataString($fields).

[String] $Template,

# Additional fields to include in the response.
[String[]] $AdditionalFields
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lint: parameter names should be singular.

$apiToken = 'perm:YWRtaW4=.NDctMA==.MskXiizMXwymP1Kfm21iR14len99jp'
$apiUrl = 'http://localhost:8080'

function Remove-AllProjects
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename to Clear-Project.

Tests/Invoke-YTRestMethod.Tests.ps1 Show resolved Hide resolved
@KhoiKy KhoiKy force-pushed the feature/basic-functions branch from c01364c to 0f1c7c3 Compare January 24, 2025 16:47
@KhoiKy KhoiKy force-pushed the feature/basic-functions branch from c21f75c to 4532698 Compare January 24, 2025 17:31
@KhoiKy KhoiKy force-pushed the feature/basic-functions branch from ebae5fa to f7ceb28 Compare January 24, 2025 19:14
@KhoiKy KhoiKy requested a review from splatteredbits January 24, 2025 23:07
@splatteredbits
Copy link
Member

Please automate the download and updating of the YouTrackConfig directory. It should not be getting checked into source.

Gets an issue from YouTrack.

.DESCRIPTION
The `Get-YTIssue` function gets an issue from YouTrack using the issue ID or issue key. The function returns the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still needs to get done.

$fields += ",$($AdditionalField -join ',')"
}

$fields = [Uri]::EscapeUriString($fields)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still needs to change.

Invokes a REST method in YouTrack.

.DESCRIPTION
The `Invoke-YTRestMethod` function invokes a REST method in YouTrack using the provided session object. Pass in the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bump.


if ($Template)
{
$fields += "&template=$Template"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bump.

$fields += "&template=$Template"
}

$fields = [Uri]::EscapeUriString($fields)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bump.

The `Resolve-YTProjectId` function takes in a project, project short name, or project id and returns the project id
associated with the project provided.

.EXAMPLE
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function name in examples is wrong.

.EXAMPLE
Resolve-YTProject.ps1 -Session $session -Project $project

Demonstrates resolving the project id for the project with a project object.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bump.

@KhoiKy KhoiKy force-pushed the feature/basic-functions branch from 0e41434 to 3f058e7 Compare January 25, 2025 00:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants