Skip to content

Commit

Permalink
1. add label opereations; 2. add test case for label
Browse files Browse the repository at this point in the history
  • Loading branch information
supereagle committed Dec 5, 2016
1 parent d23256e commit ab89733
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
7 changes: 7 additions & 0 deletions jenkins_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ func TestGetAllBuilds(t *testing.T) {
assert.Equal(t, 1, len(builds))
}

func TestGetLabel(t *testing.T) {
label, err := jenkins.GetLabel("test_label")
assert.Nil(t, err)
assert.Equal(t, label.GetName(), "test_label")
assert.Equal(t, 0, len(label.GetNodes()))
}

func TestBuildMethods(t *testing.T) {
job, _ := jenkins.GetJob("Job1_test")
build, _ := job.GetLastBuild()
Expand Down
22 changes: 22 additions & 0 deletions label.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright 2015 Vadim Kravcenko
//
// Licensed under the Apache License, Version 2.0 (the "License"): you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.

package gojenkins

type Label struct {
Expand Down Expand Up @@ -31,6 +45,14 @@ type LabelResponse struct {
TotalExecutors int64 `json:"totalExecutors"`
}

func (l *Label) GetName() string {
return l.Raw.Name
}

func (l *Label) GetNodes() []LabelNode {
return l.Raw.Nodes
}

func (l *Label) Poll() (int, error) {
response, err := l.Jenkins.Requester.GetJSON(l.Base, l.Raw, nil)
if err != nil {
Expand Down

0 comments on commit ab89733

Please sign in to comment.