Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
b2805499
Commit
b2805499
authored
Aug 03, 2015
by
Alex Mohr
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #12180 from brendandburns/queue
Fix a small bug in contrib/submit-queue, add a unit test.
parents
0f17038f
0287d6eb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
2 deletions
+76
-2
github.go
contrib/submit-queue/github/github.go
+1
-1
github_test.go
contrib/submit-queue/github/github_test.go
+75
-1
No files found.
contrib/submit-queue/github/github.go
View file @
b2805499
...
@@ -96,7 +96,7 @@ func validateLGTMAfterPush(client *github.Client, user, project string, pr *gith
...
@@ -96,7 +96,7 @@ func validateLGTMAfterPush(client *github.Client, user, project string, pr *gith
for
ix
:=
range
events
{
for
ix
:=
range
events
{
event
:=
&
events
[
ix
]
event
:=
&
events
[
ix
]
if
*
event
.
Event
==
"labeled"
&&
*
event
.
Label
.
Name
==
"lgtm"
{
if
*
event
.
Event
==
"labeled"
&&
*
event
.
Label
.
Name
==
"lgtm"
{
*
lgtmTime
=
*
event
.
CreatedAt
lgtmTime
=
event
.
CreatedAt
}
}
}
}
if
lgtmTime
==
nil
{
if
lgtmTime
==
nil
{
...
...
contrib/submit-queue/github/github_test.go
View file @
b2805499
...
@@ -24,11 +24,14 @@ import (
...
@@ -24,11 +24,14 @@ import (
"net/url"
"net/url"
"strconv"
"strconv"
"testing"
"testing"
"time"
"github.com/google/go-github/github"
"github.com/google/go-github/github"
)
)
func
stringPtr
(
val
string
)
*
string
{
return
&
val
}
func
stringPtr
(
val
string
)
*
string
{
return
&
val
}
func
timePtr
(
val
time
.
Time
)
*
time
.
Time
{
return
&
val
}
func
intPtr
(
val
int
)
*
int
{
return
&
val
}
func
TestHasLabel
(
t
*
testing
.
T
)
{
func
TestHasLabel
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
tests
:=
[]
struct
{
...
@@ -388,3 +391,74 @@ func TestComputeStatus(t *testing.T) {
...
@@ -388,3 +391,74 @@ func TestComputeStatus(t *testing.T) {
}
}
}
}
}
}
func
TestValidateLGTMAfterPush
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
issueEvents
[]
github
.
IssueEvent
shouldPass
bool
pull
github
.
PullRequest
}{
{
issueEvents
:
[]
github
.
IssueEvent
{
{
Event
:
stringPtr
(
"labeled"
),
Label
:
&
github
.
Label
{
Name
:
stringPtr
(
"lgtm"
),
},
CreatedAt
:
timePtr
(
time
.
Unix
(
10
,
0
)),
},
},
pull
:
github
.
PullRequest
{
Number
:
intPtr
(
1
),
Head
:
&
github
.
PullRequestBranch
{
Repo
:
&
github
.
Repository
{
PushedAt
:
&
github
.
Timestamp
{
time
.
Unix
(
9
,
0
)},
},
},
},
shouldPass
:
true
,
},
{
issueEvents
:
[]
github
.
IssueEvent
{
{
Event
:
stringPtr
(
"labeled"
),
Label
:
&
github
.
Label
{
Name
:
stringPtr
(
"lgtm"
),
},
CreatedAt
:
timePtr
(
time
.
Unix
(
10
,
0
)),
},
},
pull
:
github
.
PullRequest
{
Number
:
intPtr
(
1
),
Head
:
&
github
.
PullRequestBranch
{
Repo
:
&
github
.
Repository
{
PushedAt
:
&
github
.
Timestamp
{
time
.
Unix
(
11
,
0
)},
},
},
},
shouldPass
:
false
,
},
}
for
_
,
test
:=
range
tests
{
client
,
server
,
mux
:=
initTest
()
mux
.
HandleFunc
(
fmt
.
Sprintf
(
"/repos/o/r/issues/%d/events"
,
test
.
pull
.
Number
),
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
if
r
.
Method
!=
"GET"
{
t
.
Errorf
(
"Unexpected method: %s"
,
r
.
Method
)
}
w
.
WriteHeader
(
http
.
StatusOK
)
data
,
err
:=
json
.
Marshal
(
test
.
issueEvents
)
if
err
!=
nil
{
t
.
Errorf
(
"Unexpected error: %v"
,
err
)
}
w
.
Write
(
data
)
ok
,
err
:=
validateLGTMAfterPush
(
client
,
"o"
,
"r"
,
&
test
.
pull
)
if
err
!=
nil
{
t
.
Errorf
(
"unexpected error: %v"
,
err
)
}
if
ok
!=
test
.
shouldPass
{
t
.
Errorf
(
"expected: %v, saw: %v"
,
test
.
shouldPass
,
ok
)
}
})
server
.
Close
()
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment