Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
coryb committed Sep 3, 2017
1 parent dc02181 commit ba35f55
Show file tree
Hide file tree
Showing 11 changed files with 128 additions and 116 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
jira
schemas/*.json
t/.gnupg/random_seed
t/issue.props
5 changes: 4 additions & 1 deletion jiracmd/worklogList.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/coryb/oreo"
"gopkg.in/Netflix-Skunkworks/go-jira.v1"
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiracli"
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiradata"
kingpin "gopkg.in/alecthomas/kingpin.v2"
)

Expand Down Expand Up @@ -44,7 +45,9 @@ func CmdWorklogList(o *oreo.Client, globals *jiracli.GlobalOptions, opts *Worklo
if err != nil {
return err
}
if err := jiracli.RunTemplate(opts.Template.Value, data, nil); err != nil {
if err := jiracli.RunTemplate(opts.Template.Value, struct {
Worklogs *jiradata.Worklogs `json:"worklogs,omitempty" yaml:"worklogs,omitempty"`
}{data}, nil); err != nil {
return err
}
if opts.Browse.Value {
Expand Down
Binary file removed t/.gnupg/random_seed
Binary file not shown.
1 change: 1 addition & 0 deletions t/.jira.d/list.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
template: list
36 changes: 19 additions & 17 deletions t/100basic.t
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/bin/bash
eval "$(curl -q -s https://raw.githubusercontent.com/coryb/osht/master/osht.sh)"
cd $(dirname $0)
jira="../jira --project BASIC"
jira="../jira"
export JIRA_LOG_FORMAT="%{level:-5s} %{message}"

export COLUMNS=149
ENDPOINT="http://localhost:8080"
if [ -n "$JIRACLOUD" ]; then
ENDPOINT="https://go-jira.atlassian.net"
Expand All @@ -16,12 +17,12 @@ RUNS $jira logout
RUNS $jira login

# cleanup from previous failed test executions
($jira ls | awk -F: '{print $1}' | while read issue; do ../jira done $issue; done) | sed 's/^/# CLEANUP: /g'
($jira ls --project BASIC | awk -F: '{print $1}' | while read issue; do ../jira done $issue; done) | sed 's/^/# CLEANUP: /g'

###############################################################################
## Create an issue
###############################################################################
RUNS $jira create -o summary=summary -o description=description --noedit --saveFile issue.props
RUNS $jira create --project BASIC -o summary=summary -o description=description --noedit --saveFile issue.props
issue=$(awk '/issue/{print $2}' issue.props)

DIFF <<EOF
Expand Down Expand Up @@ -52,7 +53,7 @@ EOF
## List all issues, should be just the one we created
###############################################################################

RUNS $jira ls
RUNS $jira ls --project BASIC
DIFF <<EOF
$(printf %-12s $issue:) summary
EOF
Expand All @@ -61,7 +62,7 @@ EOF
## List all issues, using the table template
###############################################################################

RUNS $jira ls --template table
RUNS $jira ls --project BASIC --template table
DIFF <<EOF
+----------------+---------------------------------------------------------+--------------+--------------+------------+--------------+--------------+
| Issue | Summary | Priority | Status | Age | Reporter | Assignee |
Expand All @@ -76,7 +77,7 @@ EOF

NRUNS $jira close $issue
EDIFF <<EOF
ERROR Invalid Transition 'close', Available: To Do, In Progress, In Review, Done
ERROR Invalid Transition "close" from "To Do", Available: To Do, In Progress, In Review, Done
EOF

###############################################################################
Expand All @@ -92,21 +93,21 @@ EOF
## Verify there are no unresolved issues
###############################################################################

RUNS $jira ls
RUNS $jira ls --project BASIC
DIFF <<EOF
EOF

###############################################################################
## Setup 2 more issues so we can test duping
###############################################################################

RUNS $jira create -o summary=summary -o description=description --noedit --saveFile issue.props
RUNS $jira create --project BASIC -o summary=summary -o description=description --noedit --saveFile issue.props
issue=$(awk '/issue/{print $2}' issue.props)
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF

RUNS $jira create -o summary=dup -o description=dup --noedit --saveFile issue.props
RUNS $jira create --project BASIC -o summary=dup -o description=dup --noedit --saveFile issue.props
dup=$(awk '/issue/{print $2}' issue.props)
DIFF <<EOF
OK $dup $ENDPOINT/browse/$dup
Expand All @@ -118,7 +119,7 @@ EOF
## that issue should be resolved
###############################################################################

RUNS $jira $dup dups $issue --noedit
RUNS $jira dup $dup $issue
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
OK $dup $ENDPOINT/browse/$dup
Expand Down Expand Up @@ -146,7 +147,7 @@ EOF
## We should see only one unresolved issue, the Dup should be resolved
###############################################################################

RUNS $jira ls
RUNS $jira ls --project BASIC
DIFF <<EOF
$(printf %-12s $issue:) summary
EOF
Expand All @@ -155,7 +156,7 @@ EOF
## Setup for testing blocking issues
###############################################################################

RUNS $jira create -o summary=blocks -o description=blocks --noedit --saveFile issue.props
RUNS $jira create --project BASIC -o summary=blocks -o description=blocks --noedit --saveFile issue.props
blocker=$(awk '/issue/{print $2}' issue.props)
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
Expand All @@ -165,9 +166,10 @@ EOF
## Set blocker and verify it shows up when viewing the main issue
###############################################################################

RUNS $jira $blocker blocks $issue
RUNS $jira block $blocker $issue
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
OK $blocker $ENDPOINT/browse/$blocker
EOF

RUNS $jira $issue
Expand All @@ -192,7 +194,7 @@ EOF
## Both issues are unresolved now
###############################################################################

RUNS $jira ls
RUNS $jira ls --project BASIC
DIFF <<EOF
$(printf %-12s $issue:) summary
$(printf %-12s $blocker:) blocks
Expand Down Expand Up @@ -389,7 +391,7 @@ EOF
## Verify we can add labels to an issue
###############################################################################

RUNS $jira add labels $blocker test-label another-label
RUNS $jira labels add $blocker test-label another-label
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
Expand Down Expand Up @@ -417,7 +419,7 @@ EOF
## Verify we can remove a label
###############################################################################

RUNS $jira remove labels $blocker another-label
RUNS $jira labels remove $blocker another-label
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
Expand Down Expand Up @@ -445,7 +447,7 @@ EOF
## Verify we can replace the labels with a new set
###############################################################################

RUNS $jira set labels $blocker more-label better-label
RUNS $jira labels set $blocker more-label better-label
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
Expand Down
8 changes: 4 additions & 4 deletions t/110basic-worklog.t
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
eval "$(curl -q -s https://raw.githubusercontent.com/coryb/osht/master/osht.sh)"
cd $(dirname $0)
jira="../jira --project BASIC"
jira="../jira"
export JIRA_LOG_FORMAT="%{level:-5s} %{message}"

ENDPOINT="http://localhost:8080"
Expand All @@ -16,12 +16,12 @@ RUNS $jira logout
RUNS $jira login

# cleanup from previous failed test executions
($jira ls | awk -F: '{print $1}' | while read issue; do ../jira done $issue; done) | sed 's/^/# CLEANUP: /g'
($jira ls --project BASIC | awk -F: '{print $1}' | while read issue; do ../jira done $issue; done) | sed 's/^/# CLEANUP: /g'

###############################################################################
## Create an issue
###############################################################################
RUNS $jira create -o summary=summary -o description=description --noedit --saveFile issue.props
RUNS $jira create --project BASIC -o summary=summary -o description=description --noedit --saveFile issue.props
issue=$(awk '/issue/{print $2}' issue.props)

DIFF <<EOF
Expand All @@ -31,7 +31,7 @@ EOF
###############################################################################
## Add a worklog to an issue
###############################################################################
RUNS $jira add worklog $issue --comment "work is hard" --time-spent "1h 12m" --noedit
RUNS $jira worklog add $issue --comment "work is hard" --time-spent "1h 12m" --noedit
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF
Expand Down
35 changes: 18 additions & 17 deletions t/200scrum.t
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
eval "$(curl -q -s https://raw.githubusercontent.com/coryb/osht/master/osht.sh)"
cd $(dirname $0)
jira="../jira --project SCRUM"
jira="../jira"
export JIRA_LOG_FORMAT="%{level:-5s} %{message}"

ENDPOINT="http://localhost:8080"
Expand All @@ -12,7 +12,7 @@ fi
PLAN 84

# cleanup from previous failed test executions
($jira ls | awk -F: '{print $1}' | while read issue; do ../jira done $issue; done) | sed 's/^/# CLEANUP: /g'
($jira ls --project SCRUM | awk -F: '{print $1}' | while read issue; do ../jira done $issue; done) | sed 's/^/# CLEANUP: /g'

# reset login
RUNS $jira logout
Expand All @@ -21,7 +21,7 @@ echo "gojira123" | RUNS $jira login
###############################################################################
## Create an issue
###############################################################################
RUNS $jira create -o summary=summary -o description=description --noedit --saveFile issue.props
RUNS $jira create --project SCRUM -o summary=summary -o description=description --noedit --saveFile issue.props
issue=$(awk '/issue/{print $2}' issue.props)

DIFF <<EOF
Expand Down Expand Up @@ -52,7 +52,7 @@ EOF
## List all issues, should be just the one we created
###############################################################################

RUNS $jira ls
RUNS $jira ls --project SCRUM
DIFF <<EOF
$(printf %-12s $issue:) summary
EOF
Expand All @@ -63,7 +63,7 @@ EOF

NRUNS $jira close $issue
EDIFF <<EOF
ERROR Invalid Transition 'close', Available: To Do, In Progress, Done
ERROR Invalid Transition "close" from "To Do", Available: To Do, In Progress, Done
EOF

###############################################################################
Expand All @@ -79,21 +79,21 @@ EOF
## Verify there are no unresolved issues
###############################################################################

RUNS $jira ls
RUNS $jira ls --project SCRUM
DIFF <<EOF
EOF

###############################################################################
## Setup 2 more issues so we can test duping
###############################################################################

RUNS $jira create -o summary=summary -o description=description --noedit --saveFile issue.props
RUNS $jira create --project SCRUM -o summary=summary -o description=description --noedit --saveFile issue.props
issue=$(awk '/issue/{print $2}' issue.props)
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
EOF

RUNS $jira create -o summary=dup -o description=dup --noedit --saveFile issue.props
RUNS $jira create --project SCRUM -o summary=dup -o description=dup --noedit --saveFile issue.props
dup=$(awk '/issue/{print $2}' issue.props)
DIFF <<EOF
OK $dup $ENDPOINT/browse/$dup
Expand All @@ -105,7 +105,7 @@ EOF
## that issue should be resolved
###############################################################################

RUNS $jira $dup dups $issue --noedit
RUNS $jira dup $dup $issue
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
OK $dup $ENDPOINT/browse/$dup
Expand Down Expand Up @@ -133,7 +133,7 @@ EOF
## We should see only one unresolved issue, the Dup should be resolved
###############################################################################

RUNS $jira ls
RUNS $jira ls --project SCRUM
DIFF <<EOF
$(printf %-12s $issue:) summary
EOF
Expand All @@ -142,7 +142,7 @@ EOF
## Setup for testing blocking issues
###############################################################################

RUNS $jira create -o summary=blocks -o description=blocks --noedit --saveFile issue.props
RUNS $jira create --project SCRUM -o summary=blocks -o description=blocks --noedit --saveFile issue.props
blocker=$(awk '/issue/{print $2}' issue.props)
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
Expand All @@ -152,9 +152,10 @@ EOF
## Set blocker and verify it shows up when viewing the main issue
###############################################################################

RUNS $jira $blocker blocks $issue
RUNS $jira block $blocker $issue
DIFF <<EOF
OK $issue $ENDPOINT/browse/$issue
OK $blocker $ENDPOINT/browse/$blocker
EOF

RUNS $jira $issue
Expand All @@ -179,7 +180,7 @@ EOF
## Both issues are unresolved now
###############################################################################

RUNS $jira ls
RUNS $jira ls --project SCRUM
DIFF <<EOF
$(printf %-12s $issue:) summary
$(printf %-12s $blocker:) blocks
Expand Down Expand Up @@ -288,7 +289,7 @@ EOF

NRUNS $jira trans "review" $blocker --noedit
DIFF <<EOF
ERROR Invalid Transition 'review', Available: To Do, In Progress, Done
ERROR Invalid Transition "review" from "To Do", Available: To Do, In Progress, Done
EOF

###############################################################################
Expand Down Expand Up @@ -376,7 +377,7 @@ EOF
## Verify we can add labels to an issue
###############################################################################

RUNS $jira add labels $blocker test-label another-label
RUNS $jira labels add $blocker test-label another-label
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
Expand Down Expand Up @@ -404,7 +405,7 @@ EOF
## Verify we can remove a label
###############################################################################

RUNS $jira remove labels $blocker another-label
RUNS $jira labels remove $blocker another-label
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
Expand Down Expand Up @@ -432,7 +433,7 @@ EOF
## Verify we can replace the labels with a new set
###############################################################################

RUNS $jira set labels $blocker more-label better-label
RUNS $jira labels set $blocker more-label better-label
DIFF <<EOF
OK $blocker $ENDPOINT/browse/$blocker
EOF
Expand Down
Loading

0 comments on commit ba35f55

Please sign in to comment.