From 41d1a7c9a195b723d3fce9cb17c31533971c189a Mon Sep 17 00:00:00 2001 From: Cory Bennett Date: Sat, 28 Oct 2017 12:19:36 -0700 Subject: [PATCH] add tests for validating changes to auto-generated jiradata files --- .travis.yml | 7 +++++-- issue.go | 9 --------- jiradata/Attachment_test.go | 15 +++++++++++++++ 3 files changed, 20 insertions(+), 11 deletions(-) create mode 100644 jiradata/Attachment_test.go diff --git a/.travis.yml b/.travis.yml index ce95039..3dbd78e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,12 +5,15 @@ before_install: language: go go_import_path: gopkg.in/Netflix-Skunkworks/go-jira.v1 go: - - 1.8 + - 1.9 matrix: fast_finish: true script: + - go get -t -v ./... + - go test ./... - make vet - make - - make prove 2>&1 + - make prove 2>&1 + diff --git a/issue.go b/issue.go index 5ddfb10..eb14f6f 100644 --- a/issue.go +++ b/issue.go @@ -571,15 +571,6 @@ func IssueAttachFile(ua HttpClient, endpoint string, issue, filename string, con defer resp.Body.Close() if resp.StatusCode == 200 { - // FIXME move this to a test, and run go tests as part of our regression - if false { - // this is because schema is wrong, defaults to type `int`, so we manually change it - // to `string`. If the jiradata is regenerated we need to manually make the change - // again. - log.Debugf("Assert Attachment.ID is a string, rather than int: %v", &jiradata.Attachment{ - ID: jiradata.IntOrString(0), - }) - } results := jiradata.ListOfAttachment{} return &results, readJSON(resp.Body, &results) } diff --git a/jiradata/Attachment_test.go b/jiradata/Attachment_test.go new file mode 100644 index 0000000..cb3a343 --- /dev/null +++ b/jiradata/Attachment_test.go @@ -0,0 +1,15 @@ +package jiradata + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestAttachmentID(t *testing.T) { + // this is because schema is wrong, defaults to type `int`, so we manually change it + // to `string`. If the jiradata is regenerated we need to manually make the change + // again to include: + // ID IntOrString `json:"id,omitempty" yaml:"id,omitempty"` + assert.IsType(t, IntOrString(0), Attachment{}.ID) +}