aboutsummaryrefslogtreecommitdiffstats
path: root/bridge/github/iterator_test.go
diff options
context:
space:
mode:
authorAmine Hilaly <hilalyamine@gmail.com>2019-04-21 21:26:42 +0200
committerAmine Hilaly <hilalyamine@gmail.com>2019-05-05 18:16:10 +0200
commitc8ad4dbfd9511f4cfa748fa85c01fbca2edb348a (patch)
tree42342fdb9d2c8463dc2487c318fef1a358410841 /bridge/github/iterator_test.go
parentc0c8b11549930210688a06c64b3cc68d2159a0e8 (diff)
downloadgit-bug-c8ad4dbfd9511f4cfa748fa85c01fbca2edb348a.tar.gz
Add github iterator
use `goto` in .Next* functions Update iterator.go
Diffstat (limited to 'bridge/github/iterator_test.go')
-rw-r--r--bridge/github/iterator_test.go44
1 files changed, 44 insertions, 0 deletions
diff --git a/bridge/github/iterator_test.go b/bridge/github/iterator_test.go
new file mode 100644
index 00000000..c5820973
--- /dev/null
+++ b/bridge/github/iterator_test.go
@@ -0,0 +1,44 @@
+package github
+
+import (
+ "fmt"
+ "os"
+ "testing"
+ "time"
+)
+
+func Test_Iterator(t *testing.T) {
+ token := os.Getenv("GITHUB_TOKEN")
+ user := os.Getenv("GITHUB_USER")
+ project := os.Getenv("GITHUB_PROJECT")
+
+ i := newIterator(map[string]string{
+ keyToken: token,
+ "user": user,
+ "project": project,
+ }, time.Now().Add(-14*24*time.Hour))
+
+ for i.NextIssue() {
+ v := i.IssueValue()
+ fmt.Printf("issue = id:%v title:%v\n", v.Id, v.Title)
+
+ for i.NextIssueEdit() {
+ v := i.IssueEditValue()
+ fmt.Printf("issue edit = %v\n", string(*v.Diff))
+ }
+
+ for i.NextTimeline() {
+ v := i.TimelineValue()
+ fmt.Printf("timeline = type:%v\n", v.Typename)
+
+ if v.Typename == "IssueComment" {
+ for i.NextCommentEdit() {
+ _ = i.CommentEditValue()
+
+ //fmt.Printf("comment edit: %v\n", *v.Diff)
+ fmt.Printf("comment edit\n")
+ }
+ }
+ }
+ }
+}