issues

Github, Jira, Gitlab issues from Plan 9's acme
Log | Files | Refs | README | LICENSE

jira_test.go (1133B)


      1 package jira
      2 
      3 import (
      4 	"encoding/json"
      5 	"os"
      6 	"testing"
      7 	"time"
      8 )
      9 
     10 func TestDecode(t *testing.T) {
     11 	name := "testdata/issue/TEST-1"
     12 	f, err := os.Open(name)
     13 	if err != nil {
     14 		t.Fatal(err)
     15 	}
     16 	defer f.Close()
     17 
     18 	var issue Issue
     19 	if err := json.NewDecoder(f).Decode(&issue); err != nil {
     20 		t.Fatal(err)
     21 	}
     22 
     23 	want := Issue{
     24 		ID:      "10148",
     25 		URL:     "https://jira.atlassian.com/rest/api/latest/issue/10148",
     26 		Key:     "TEST-1",
     27 		Created: time.Date(2002, time.Month(2), 8, 5, 8, 0, 0, time.UTC),
     28 		Updated: time.Date(2022, time.Month(5), 18, 18, 35, 49, 533*1e6, time.UTC),
     29 	}
     30 
     31 	if !issue.Created.Equal(want.Created) {
     32 		t.Errorf("Created: got %s want %s", issue.Created, want.Created)
     33 	}
     34 	if !issue.Updated.Equal(want.Updated) {
     35 		t.Errorf("Updated: got %s want %s", issue.Updated, want.Updated)
     36 	}
     37 
     38 	if len(issue.Links) == 0 {
     39 		t.Errorf("Links: no linked issues decoded")
     40 	}
     41 }
     42 
     43 /*
     44 func TestSubtasks(t *testing.T) {
     45 	f, err := os.Open("testdata/subtasks")
     46 	if err != nil {
     47 		t.Fatal(err)
     48 	}
     49 	defer f.Close()
     50 	var is Issue
     51 	if err := json.NewDecoder(f).Decode(&is); err != nil {
     52 		t.Fatal(err)
     53 	}
     54 	fmt.Println(is.Subtasks)
     55 }
     56 */