-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
506 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,35 @@ | ||
package client | ||
|
||
import ( | ||
"strings" | ||
) | ||
|
||
// Job | ||
type Job struct { | ||
// actions | ||
Description string `xml:"description"` | ||
DisplayName string `xml:"displayName"` | ||
DisplayNameOrNull string `xml:"displayNameOrNull"` | ||
FullDisplayName string `xml:"fullDisplayName"` | ||
FullName string `xml:"fullName"` | ||
Name string `xml:"name"` | ||
URL string `xml:"url"` | ||
Buildable bool `xml:"buildable"` | ||
// builds | ||
Color string `xml:"color"` | ||
// firstBuild | ||
// healthReport | ||
// inQueue | ||
// keepDependencies | ||
// lastBuild | ||
// lastCompletedBuild | ||
// lastFailedBuild | ||
// lastStableBuild | ||
// lastSuccessfulBuild | ||
// lastUnstableBuild | ||
// lastUnsuccessfulBuild | ||
NextBuildNumber int64 `xml:"nextBuildNumber"` | ||
Property *[]*JobConfigProperty `xml:"property"` | ||
// queueItem | ||
ConcurrentBuild bool `xml:"concurrentBuild"` | ||
ResumeBlocked bool `xml:"resumeBlocked"` | ||
Name string | ||
Disabled bool | ||
Description string | ||
} | ||
|
||
// NewJob return Job object with default values | ||
func NewJob() *Job { | ||
return &Job{} | ||
} | ||
|
||
func (job *Job) Folder() string { | ||
nameParts := strings.Split(job.Name, "/") | ||
return strings.Join(nameParts[:len(nameParts)-1], "/") | ||
} | ||
|
||
func (job *Job) NameOnly() string { | ||
nameParts := strings.Split(job.Name, "/") | ||
return nameParts[len(nameParts)-1] | ||
} | ||
|
||
func newJobFromConfigAndDetails(config *jobConfig, details *jobDetails) *Job { | ||
return &Job{ | ||
Name: details.FullName, | ||
Disabled: config.Disabled, | ||
Description: details.Description, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package client | ||
|
||
type jobDetails struct { | ||
// actions | ||
Description string `xml:"description"` | ||
DisplayName string `xml:"displayName"` | ||
DisplayNameOrNull string `xml:"displayNameOrNull"` | ||
FullDisplayName string `xml:"fullDisplayName"` | ||
FullName string `xml:"fullName"` | ||
Name string `xml:"name"` | ||
URL string `xml:"url"` | ||
Buildable bool `xml:"buildable"` | ||
// builds | ||
Color string `xml:"color"` | ||
// firstBuild | ||
// healthReport | ||
// inQueue | ||
// keepDependencies | ||
// lastBuild | ||
// lastCompletedBuild | ||
// lastFailedBuild | ||
// lastStableBuild | ||
// lastSuccessfulBuild | ||
// lastUnstableBuild | ||
// lastUnsuccessfulBuild | ||
NextBuildNumber int64 `xml:"nextBuildNumber"` | ||
Property *[]*JobConfigProperty `xml:"property"` | ||
// queueItem | ||
ConcurrentBuild bool `xml:"concurrentBuild"` | ||
ResumeBlocked bool `xml:"resumeBlocked"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package client | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestJobDetailNameOnly(t *testing.T) { | ||
job := Job{Name: "fee fi/fo/fum"} | ||
expected := "fum" | ||
if job.NameOnly() != expected { | ||
t.Fatalf("job name only should be %v, was %v", expected, job.NameOnly()) | ||
} | ||
} | ||
|
||
func TestJobDetailFolder(t *testing.T) { | ||
job := Job{Name: "fee fi/fo/fum"} | ||
expected := "fee fi/fo" | ||
if job.Folder() != expected { | ||
t.Fatalf("job folder should be %v, was %v", expected, job.Folder()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.