Beispiel #1
0
func TestJiraFetchWithRecording(t *testing.T) {
	resource.Require(t, resource.UnitTest)
	r, err := recorder.New("../test/data/jira_fetch_test")
	if err != nil {
		t.Error(err)
	}
	defer r.Stop()

	h := &http.Client{
		Timeout:   100 * time.Second,
		Transport: r.Transport,
	}

	f := jiraIssueFetcher{}
	j := JiraTracker{URL: "https://issues.jboss.org", Query: "project = Arquillian AND status = Closed AND assignee = aslak AND fixVersion = 1.1.11.Final AND priority = Major ORDER BY created ASC"}
	client, _ := jira.NewClient(h, j.URL)
	f.client = client
	fetch := j.fetch(&f)

	i := <-fetch
	if i.ID != `"ARQ-1937"` {
		t.Errorf("ID is not matching: %#v", string(i.ID))
	}

	i = <-fetch
	if i.ID != `"ARQ-1956"` {
		t.Errorf("ID is not matching: %#v", string(i.ID))
	}

	i = <-fetch
	if i.ID != `"ARQ-1996"` {
		t.Errorf("ID is not matching: %#v", string(i.ID))
	}

	i = <-fetch
	if i.ID != `"ARQ-2009"` {
		t.Errorf("ID is not matching: %#v", string(i.ID))
	}
}
Beispiel #2
0
// Start the Jira client goroutine
func Start(config *model.Config, wg *sync.WaitGroup,
	commandrouter *commandrouter.Router,
	outChan chan *model.ChatMessage, done chan struct{}) {

	wg.Add(1)

	httpClient := http.Client{}
	httpClient.Timeout = time.Duration(config.RequestTimeout) * time.Millisecond
	jiraClient, err := jira.NewClient(nil, config.JiraUrl)
	if err != nil {
		panic(err)
	}

	processor := &JiraCommands{
		Client: jiraClient,
	}

	incoming, err := commandrouter.AddDestination("JiraCommands", commands)
	if err != nil {
		panic(err)
	}

	go func() {
	Loop:
		for {
			select {
			case match := <-incoming:
				match.Response <- processor.Process(match.Tag, match.Message)
			case <-done:
				break Loop
			}
		}
		wg.Done()
	}()

}
Beispiel #3
0
// Fetch collects data from Jira
func (j *JiraTracker) Fetch() chan TrackerItemContent {
	f := jiraIssueFetcher{}
	client, _ := jira.NewClient(nil, j.URL)
	f.client = client
	return j.fetch(&f)
}