Repository: ctreminiom/go-atlassian
Pull request #173 (2023-03-05 17:40:51)

:white_check_mark: Added more test-cases under the models/ folder


Patch:
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index a931932..5e633e2 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -3,47 +3,39 @@ on:
   push:
     tags:
       - v*
-    branches: [ main, dev, feature/* ]
+    branches:
+      - master
+      - main
+      - feature/*
   pull_request:
-    branches: [ main ]
 permissions:
   contents: read
   # Optional: allow read access to pull request. Use with `only-new-issues` option.
   # pull-requests: read
 jobs:
   golangci:
-
-    max-parallel: 2
-    matrix:
-      go-version: [ 1.16, 1.17 ]
-      os: [ ubuntu-latest, macos-latest, windows-latest ]
-
+    strategy:
+      matrix:
+        go: [1.17, 1.18, 1.19]
+        os: [macos-latest, windows-latest]
     name: lint
     runs-on: ${{ matrix.os }}
     steps:
       - uses: actions/setup-go@v3
+        with:
+          go-version: ${{ matrix.go }}
       - uses: actions/checkout@v3
       - name: golangci-lint
         uses: golangci/golangci-lint-action@v3
         with:
-          # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
-          version: v1.29
-
+          # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
+          version: v1.49
           # Optional: working directory, useful for monorepos
           # working-directory: somedir
 
           # Optional: golangci-lint command line arguments.
           # args: --issues-exit-code=0
+          args: --timeout=3m
 
           # Optional: show only new issues if it's a pull request. The default value is `false`.
-          # only-new-issues: true
-
-          # Optional: if set to true then the all caching functionality will be complete disabled,
-          #           takes precedence over all other caching options.
-          # skip-cache: true
-
-          # Optional: if set to true then the action don't cache or restore ~/go/pkg.
-          # skip-pkg-cache: true
-
-          # Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
-          # skip-build-cache: true
+          # only-new-issues: true
\ No newline at end of file
diff --git a/pkg/infra/models/admin_scim_user.go b/pkg/infra/models/admin_scim_user.go
index 266d3d2..3898e4b 100644
--- a/pkg/infra/models/admin_scim_user.go
+++ b/pkg/infra/models/admin_scim_user.go
@@ -1,7 +1,5 @@
 package models
 
-import "fmt"
-
 type SCIMUserScheme struct {
 	ID                string                        `json:"id"`
 	ExternalID        string                        `json:"externalId"`
@@ -86,18 +84,18 @@ type SCIMUserToPathScheme struct {
 	Operations []*SCIMUserToPathOperationScheme `json:"operations,omitempty"`
 }
 
-func (s *SCIMUserToPathScheme) AddStringOperation(operation, path, value string) (err error) {
+func (s *SCIMUserToPathScheme) AddStringOperation(operation, path, value string) error {
 
-	if len(operation) == 0 {
-		return fmt.Errorf("error!, please provide a valid operation value, you can check the availables values calling the user schemas")
+	if operation == "" {
+		return ErrNoSCIMOperationError
 	}
 
-	if len(path) == 0 {
-		return fmt.Errorf("error!, please provide a valid path value")
+	if path == "" {
+		return ErrNoSCIMPathError
 	}
 
-	if len(value) == 0 {
-		return fmt.Errorf("error!, please provide a valid value value")
+	if value == "" {
+		return ErrNoSCIMValueError
 	}
 
 	s.Operations = append(s.Operations, &SCIMUserToPathOperationScheme{
@@ -106,17 +104,17 @@ func (s *SCIMUserToPathScheme) AddStringOperation(operation, path, value string)
 		Value: value,
 	})
 
-	return
+	return nil
 }
 
-func (s *SCIMUserToPathScheme) AddBoolOperation(operation, path string, value bool) (err error) {
+func (s *SCIMUserToPathScheme) AddBoolOperation(operation, path string, value bool) error {
 
-	if len(operation) == 0 {
-		return fmt.Errorf("error!, please provide a valid operation value, you can check the availables values calling the user schemas")
+	if operation == "" {
+		return ErrNoSCIMOperationError
 	}
 
-	if len(path) == 0 {
-		return fmt.Errorf("error!, please provide a valid path value")
+	if path == "" {
+		return ErrNoSCIMPathError
 	}
 
 	s.Operations = append(s.Operations, &SCIMUserToPathOperationScheme{
@@ -125,25 +123,25 @@ func (s *SCIMUserToPathScheme) AddBoolOperation(operation, path string, value bo
 		Value: value,
 	})
 
-	return
+	return nil
 }
 
-func (s *SCIMUserToPathScheme) AddComplexOperation(operation, path string, values []*SCIMUserComplexOperationScheme) (err error) {
+func (s *SCIMUserToPathScheme) AddComplexOperation(operation, path string, values []*SCIMUserComplexOperationScheme) error {
 
-	if len(operation) == 0 {
-		return fmt.Errorf("error!, please provide a valid operation value, you can check the availables values calling the user schemas")
+	if operation == "" {
+		return ErrNoSCIMOperationError
 	}
 
-	if len(path) == 0 {
-		return fmt.Errorf("error!, please provide a valid path value")
+	if path == "" {
+		return ErrNoSCIMPathError
 	}
 
 	if values == nil {
-		return fmt.Errorf("error!, please provide a valid SCIMUserComplexOperationScheme slice pointer")
+		return ErrNoSCIMComplexValueError
 	}
 
 	if len(values) == 0 {
-		return fmt.Errorf("error!, the values variable must contains SCIMUserComplexOperationScheme nodes")
+		return ErrNoSCIMComplexValueError
 	}
 
 	s.Operations = append(s.Operations, &SCIMUserToPathOperationScheme{
@@ -152,7 +150,7 @@ func (s *SCIMUserToPathScheme) AddComplexOperation(operation, path string, value
 		Value: values,
 	})
 
-	return
+	return nil
 }
 
 type SCIMUserComplexOperationScheme struct {
diff --git a/pkg/infra/models/errors.go b/pkg/infra/models/errors.go
index 1791d97..86ccaa4 100644
--- a/pkg/infra/models/errors.go
+++ b/pkg/infra/models/errors.go
@@ -5,6 +5,10 @@ import (
 )
 
 var (
+	ErrNoSCIMComplexValueError             = errors.New("admin: no scim complex value set")
+	ErrNoSCIMValueError                    = errors.New("admin: no scim value set")
+	ErrNoSCIMPathError                     = errors.New("admin: no scim path set")
+	ErrNoSCIMOperationError                = errors.New("admin: no scim operation value set")
 	ErrNoAdminOrganizationError            = errors.New("admin: no organization id set")
 	ErrNoAdminDomainIDError                = errors.New("admin: no domain id set")
 	ErrNoEventIDError                      = errors.New("admin: no event id set")
diff --git a/pkg/infra/models/jira_issue_custom_fields.go b/pkg/infra/models/jira_issue_custom_fields.go
index 0da4fc4..fcea27b 100644
--- a/pkg/infra/models/jira_issue_custom_fields.go
+++ b/pkg/infra/models/jira_issue_custom_fields.go
@@ -149,7 +149,7 @@ func ParseCascadingSelectCustomField(buffer bytes.Buffer, customField string) (*
 	}
 
 	customFields := fields.(map[string]interface{})
-	cascading := &CascadingSelectScheme{}
+	var cascading *CascadingSelectScheme
 
 	switch option := customFields[customField].(type) {
 	case map[string]interface{}:
@@ -233,7 +233,7 @@ func ParseUserPickerCustomField(buffer bytes.Buffer, customField string) (*UserD
 	}
 
 	customFields := fields.(map[string]interface{})
-	user := &UserDetailScheme{}
+	var user *UserDetailScheme
 
 	switch option := customFields[customField].(type) {
 	case map[string]interface{}:
@@ -272,19 +272,20 @@ func ParseFloatCustomField(buffer bytes.Buffer, customField string) (float64, er
 	if !containsFields {
 		return 0, ErrNoFieldInformationError
 	}
-
+	var number float64
 	customFields := fields.(map[string]interface{})
+
 	switch value := customFields[customField].(type) {
 
 	case float64:
-		return value, nil
+		number = value
 	case nil:
 		return 0, nil
 	default:
 		return 0, ErrNoMultiSelectTypeError
 	}
 
-	return 0, err
+	return number, err
 }
 
 func ParseLabelCustomField(buffer bytes.Buffer, customField string) ([]string, error) {
@@ -374,7 +375,7 @@ func ParseSelectCustomField(buffer bytes.Buffer, customField string) (*CustomFie
 	}
 
 	customFields := fields.(map[string]interface{})
-	cascading := &CustomFieldContextOptionScheme{}
+	var cascading *CustomFieldContextOptionScheme
 
 	switch option := customFields[customField].(type) {
 	case map[string]interface{}:
diff --git a/pkg/infra/models/sm_request_field.go b/pkg/infra/models/sm_request_field.go
index f0cebdc..05e2e70 100644
--- a/pkg/infra/models/sm_request_field.go
+++ b/pkg/infra/models/sm_request_field.go
@@ -32,7 +32,6 @@ func (c *CreateCustomerRequestPayloadScheme) MergeFields(fields *CustomerRequest
 
 	//For each customField created, merge it into the eAsMap
 	for _, field := range fields.Fields {
-
 		if err := mergo.Merge(&issueSchemeAsMap, field, mergo.WithOverride); err != nil {
 			return nil, err
 		}


Test patch:
diff --git a/pkg/infra/models/admin_scim_user_test.go b/pkg/infra/models/admin_scim_user_test.go
new file mode 100644
index 0000000..7cc5a0d
--- /dev/null
+++ b/pkg/infra/models/admin_scim_user_test.go
@@ -0,0 +1,259 @@
+package models
+
+import (
+	"github.com/stretchr/testify/assert"
+	"testing"
+)
+
+func TestSCIMUserToPathScheme_AddStringOperation(t *testing.T) {
+	type fields struct {
+		Schemas    []string
+		Operations []*SCIMUserToPathOperationScheme
+	}
+	type args struct {
+		operation string
+		path      string
+		value     string
+	}
+	testCases := []struct {
+		name    string
+		fields  fields
+		args    args
+		wantErr bool
+		Err     error
+	}{
+		{
+			name:   "when the parameters are correct",
+			fields: fields{},
+			args: args{
+				operation: "operator_sample",
+				path:      "path_sample",
+				value:     "value_sample",
+			},
+			wantErr: false,
+			Err:     nil,
+		},
+
+		{
+			name:   "when the operation is not provided",
+			fields: fields{},
+			args: args{
+				operation: "",
+				path:      "path_sample",
+				value:     "value_sample",
+			},
+			wantErr: true,
+			Err:     ErrNoSCIMOperationError,
+		},
+
+		{
+			name:   "when the path is not provided",
+			fields: fields{},
+			args: args{
+				operation: "operator_sample",
+				path:      "",
+				value:     "value_sample",
+			},
+			wantErr: true,
+			Err:     ErrNoSCIMPathError,
+		},
+
+		{
+			name:   "when the value is not provided",
+			fields: fields{},
+			args: args{
+				operation: "operator_sample",
+				path:      "path_sample",
+				value:     "",
+			},
+			wantErr: true,
+			Err:     ErrNoSCIMValueError,
+		},
+	}
+	for _, testCase := range testCases {
+		t.Run(testCase.name, func(t *testing.T) {
+			s := &SCIMUserToPathScheme{
+				Schemas:    testCase.fields.Schemas,
+				Operations: testCase.fields.Operations,
+			}
+
+			err := s.AddStringOperation(testCase.args.operation, testCase.args.path, testCase.args.value)
+			if testCase.wantErr {
+
+				if err != nil {
+					t.Logf("error returned: %v", err.Error())
+				}
+				assert.EqualError(t, err, testCase.Err.Error())
+
+			} else {
+				assert.NoError(t, err)
+			}
+		})
+	}
+}
+
+func TestSCIMUserToPathScheme_AddBoolOperation(t *testing.T) {
+	type fields struct {
+		Schemas    []string
+		Operations []*SCIMUserToPathOperationScheme
+	}
+	type args struct {
+		operation string
+		path      string
+		value     bool
+	}
+	testCases := []struct {
+		name    string
+		fields  fields
+		args    args
+		wantErr bool
+		Err     error
+	}{
+		{
+			name:   "when the parameters are correct",
+			fields: fields{},
+			args: args{
+				operation: "operator_sample",
+				path:      "path_sample",
+				value:     true,
+			},
+			wantErr: false,
+			Err:     nil,
+		},
+
+		{
+			name:   "when the operation is not provided",
+			fields: fields{},
+			args: args{
+				operation: "",
+				path:      "path_sample",
+				value:     true,
+			},
+			wantErr: true,
+			Err:     ErrNoSCIMOperationError,
+		},
+
+		{
+			name:   "when the path is not provided",
+			fields: fields{},
+			args: args{
+				operation: "operator_sample",
+				path:      "",
+				value:     true,
+			},
+			wantErr: true,
+			Err:     ErrNoSCIMPathError,
+		},
+	}
+	for _, testCase := range testCases {
+		t.Run(testCase.name, func(t *testing.T) {
+			s := &SCIMUserToPathScheme{
+				Schemas:    testCase.fields.Schemas,
+				Operations: testCase.fields.Operations,
+			}
+
+			err := s.AddBoolOperation(testCase.args.operation, testCase.args.path, testCase.args.value)
+			if testCase.wantErr {
+
+				if err != nil {
+					t.Logf("error returned: %v", err.Error())
+				}
+				assert.EqualError(t, err, testCase.Err.Error())
+
+			} else {
+				assert.NoError(t, err)
+			}
+		})
+	}
+}
+
+func TestSCIMUserToPathScheme_AddComplexOperation(t *testing.T) {
+	type fields struct {
+		Schemas    []string
+		Operations []*SCIMUserToPathOperationScheme
+	}
+	type args struct {
+		operation string
+		path      string
+		values    []*SCIMUserComplexOperationScheme
+	}
+	testCases := []struct {
+		name    string
+		fields  fields
+		args    args
+		wantErr bool
+		Err     error
+	}{
+		{
+			name:   "when the parameters are correct",
+			fields: fields{},
+			args: args{
+				operation: "operator_sample",
+				path:      "path_sample",
+				values: []*SCIMUserComplexOperationScheme{
+					{
+						Value:     "value_sample",
+						ValueType: "value_type_sample",
+						Primary:   false,
+					},
+				},
+			},
+			wantErr: false,
+			Err:     nil,
+		},
+
+		{
+			name:   "when the operation is not provided",
+			fields: fields{},
+			args: args{
+				operation: "",
+				path:      "path_sample",
+			},
+			wantErr: true,
+			Err:     ErrNoSCIMOperationError,
+		},
+
+		{
+			name:   "when the path is not provided",
+			fields: fields{},
+			args: args{
+				operation: "operator_sample",
+				path:      "",
+			},
+			wantErr: true,
+			Err:     ErrNoSCIMPathError,
+		},
+
+		{
+			name:   "when the value is not provided",
+			fields: fields{},
+			args: args{
+				operation: "operator_sample",
+				path:      "path_sample",
+				values:    nil,
+			},
+			wantErr: true,
+			Err:     ErrNoSCIMComplexValueError,
+		},
+	}
+	for _, testCase := range testCases {
+		t.Run(testCase.name, func(t *testing.T) {
+			s := &SCIMUserToPathScheme{
+				Schemas:    testCase.fields.Schemas,
+				Operations: testCase.fields.Operations,
+			}
+
+			err := s.AddComplexOperation(testCase.args.operation, testCase.args.path, testCase.args.values)
+			if testCase.wantErr {
+
+				if err != nil {
+					t.Logf("error returned: %v", err.Error())
+				}
+				assert.EqualError(t, err, testCase.Err.Error())
+
+			} else {
+				assert.NoError(t, err)
+			}
+		})
+	}
+}
diff --git a/pkg/infra/models/jira_comment_v3_test.go b/pkg/infra/models/jira_comment_v3_test.go
new file mode 100644
index 0000000..df9b967
--- /dev/null
+++ b/pkg/infra/models/jira_comment_v3_test.go
@@ -0,0 +1,45 @@
+package models
+
+import "testing"
+
+func TestCommentNodeScheme_AppendNode(t *testing.T) {
+	type fields struct {
+		Version int
+		Type    string
+		Content []*CommentNodeScheme
+		Text    string
+		Attrs   map[string]interface{}
+		Marks   []*MarkScheme
+	}
+	type args struct {
+		node *CommentNodeScheme
+	}
+	testCases := []struct {
+		name   string
+		fields fields
+		args   args
+	}{
+		{
+			name:   "when the parameters are correct",
+			fields: fields{},
+			args: args{
+				node: &CommentNodeScheme{
+					Type: "text",
+				},
+			},
+		},
+	}
+	for _, testCase := range testCases {
+		t.Run(testCase.name, func(t *testing.T) {
+			n := &CommentNodeScheme{
+				Version: testCase.fields.Version,
+				Type:    testCase.fields.Type,
+				Content: testCase.fields.Content,
+				Text:    testCase.fields.Text,
+				Attrs:   testCase.fields.Attrs,
+				Marks:   testCase.fields.Marks,
+			}
+			n.AppendNode(testCase.args.node)
+		})
+	}
+}
diff --git a/pkg/infra/models/jira_issue_custom_fields_test.go b/pkg/infra/models/jira_issue_custom_fields_test.go
index 596d238..e98432e 100644
--- a/pkg/infra/models/jira_issue_custom_fields_test.go
+++ b/pkg/infra/models/jira_issue_custom_fields_test.go
@@ -1060,6 +1060,7 @@ func TestParseUserPickerCustomField(t *testing.T) {
     "customfield_10045": {
       "self": "https://ctreminiom.atlassian.net/rest/api/3/user?accountId=5e5f6acefc1fca0af44135f8",
       "accountId": "5e5f6acefc1fca0af44135f8",
+	  "emailAddress": "example@example.com",
       "avatarUrls": {
         "48x48": "https://secure.gravatar.com/avatar/6c20a29c5ab36b3cbc121782edaadfc9?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FEN-4.png",
         "24x24": "https://secure.gravatar.com/avatar/6c20a29c5ab36b3cbc121782edaadfc9?d=https%3A%2F%2Favatar-management--avatars.us-west-2.prod.public.atl-paas.net%2Finitials%2FEN-4.png",
@@ -1136,7 +1137,7 @@ func TestParseUserPickerCustomField(t *testing.T) {
 			want: &UserDetailScheme{
 				Self:         "https://ctreminiom.atlassian.net/rest/api/3/user?accountId=5e5f6acefc1fca0af44135f8",
 				AccountID:    "5e5f6acefc1fca0af44135f8",
-				EmailAddress: "",
+				EmailAddress: "example@example.com",
 				DisplayName:  "Eduardo Navarro",
 				Active:       true,
 				TimeZone:     "Europe/London",
@@ -1471,7 +1472,8 @@ func TestParseSprintCustomField(t *testing.T) {
         "boardId": 4,
         "goal": "",
         "startDate": "2023-03-04T02:03:16.273Z",
-        "endDate": "2023-03-17T02:03:00.000Z"
+        "endDate": "2023-03-17T02:03:00.000Z",
+		"completeDate": "2023-03-04T02:03:16.273Z"
       }
     ]
 	}
@@ -1539,6 +1541,7 @@ func TestParseSprintCustomField(t *testing.T) {
 					State:         "active",
 					Name:          "KP Sprint 3",
 					StartDate:     "2023-03-04T02:03:16.273Z",
+					CompleteDate:  "2023-03-04T02:03:16.273Z",
 					EndDate:       "2023-03-17T02:03:00.000Z",
 					OriginBoardID: 4,
 					Goal:          "",
diff --git a/pkg/infra/models/jira_issue_v2_test.go b/pkg/infra/models/jira_issue_v2_test.go
index aa019da..547c712 100644
--- a/pkg/infra/models/jira_issue_v2_test.go
+++ b/pkg/infra/models/jira_issue_v2_test.go
@@ -8,7 +8,10 @@ import (
 func TestIssueSchemeV2_MergeCustomFields(t *testing.T) {
 
 	var customFields = &CustomFields{}
-	customFields.Number("customfield_10043", 1000.3232)
+	err := customFields.Number("customfield_10043", 1000.3232)
+	if err != nil {
+		t.Error(err)
+	}
 
 	type fields struct {
 		ID          string
@@ -97,7 +100,10 @@ func TestIssueSchemeV2_MergeCustomFields(t *testing.T) {
 func TestIssueSchemeV2_MergeOperations(t *testing.T) {
 
 	var operations = &UpdateOperations{}
-	operations.AddArrayOperation("labels", map[string]string{"triaged": "remove"})
+	err := operations.AddArrayOperation("labels", map[string]string{"triaged": "remove"})
+	if err != nil {
+		t.Error(err)
+	}
 
 	type fields struct {
 		ID          string
@@ -187,3 +193,63 @@ func TestIssueSchemeV2_MergeOperations(t *testing.T) {
 		})
 	}
 }
+
+func TestIssueSchemeV2_ToMap(t *testing.T) {
+	type fields struct {
+		ID          string
+		Key         string
+		Self        string
+		Transitions []*IssueTransitionScheme
+		Changelog   *IssueChangelogScheme
+		Fields      *IssueFieldsSchemeV2
+	}
+	testCases := []struct {
+		name    string
+		fields  fields
+		want    map[string]interface{}
+		wantErr bool
+		Err     error
+	}{
+		{
+			name: "when the parameters are correct",
+			fields: fields{
+				Key: "DUMMY-1",
+				Fields: &IssueFieldsSchemeV2{
+					Summary: "Test",
+				},
+			},
+			want: map[string]interface{}{
+				"key": "DUMMY-1",
+				"fields": map[string]interface{}{
+					"summary": "Test",
+				},
+			},
+			wantErr: false,
+		},
+	}
+	for _, testCase := range testCases {
+		t.Run(testCase.name, func(t *testing.T) {
+			i := &IssueSchemeV2{
+				ID:          testCase.fields.ID,
+				Key:         testCase.fields.Key,
+				Self:        testCase.fields.Self,
+				Transitions: testCase.fields.Transitions,
+				Changelog:   testCase.fields.Changelog,
+				Fields:      testCase.fields.Fields,
+			}
+			got, err := i.ToMap()
+
+			if (err != nil) != testCase.wantErr {
+				t.Errorf("ToMap() error = %v, wantErr %v", err, testCase.wantErr)
+				return
+			}
+			if !reflect.DeepEqual(got, testCase.want) {
+				t.Errorf("ToMap() got = %v, want %v", got, testCase.want)
+			}
+
+			if !reflect.DeepEqual(err, testCase.Err) {
+				t.Errorf("ToMap() got = (%v), want (%v)", err, testCase.Err)
+			}
+		})
+	}
+}
diff --git a/pkg/infra/models/jira_issue_v3_test.go b/pkg/infra/models/jira_issue_v3_test.go
index cca9143..c7d2078 100644
--- a/pkg/infra/models/jira_issue_v3_test.go
+++ b/pkg/infra/models/jira_issue_v3_test.go
@@ -8,8 +8,10 @@ import (
 func TestIssueScheme_MergeCustomFields(t *testing.T) {
 
 	var customFields = &CustomFields{}
-	customFields.Number("customfield_10043", 1000.3232)
-
+	err := customFields.Number("customfield_10043", 1000.3232)
+	if err != nil {
+		t.Error(err)
+	}
 	type fields struct {
 		ID          string
 		Key         string
@@ -97,7 +99,10 @@ func TestIssueScheme_MergeCustomFields(t *testing.T) {
 func TestIssueScheme_MergeOperations(t *testing.T) {
 
 	var operations = &UpdateOperations{}
-	operations.AddArrayOperation("labels", map[string]string{"triaged": "remove"})
+	err := operations.AddArrayOperation("labels", map[string]string{"triaged": "remove"})
+	if err != nil {
+		t.Error(err)
+	}
 
 	type fields struct {
 		ID          string
@@ -187,3 +192,63 @@ func TestIssueScheme_MergeOperations(t *testing.T) {
 		})
 	}
 }
+
+func TestIssueScheme_ToMap(t *testing.T) {
+	type fields struct {
+		ID          string
+		Key         string
+		Self        string
+		Transitions []*IssueTransitionScheme
+		Changelog   *IssueChangelogScheme
+		Fields      *IssueFieldsScheme
+	}
+	testCases := []struct {
+		name    string
+		fields  fields
+		want    map[string]interface{}
+		wantErr bool
+		Err     error
+	}{
+		{
+			name: "when the parameters are correct",
+			fields: fields{
+				Key: "DUMMY-1",
+				Fields: &IssueFieldsScheme{
+					Summary: "Test",
+				},
+			},
+			want: map[string]interface{}{
+				"key": "DUMMY-1",
+				"fields": map[string]interface{}{
+					"summary": "Test",
+				},
+			},
+			wantErr: false,
+		},
+	}
+	for _, testCase := range testCases {
+		t.Run(testCase.name, func(t *testing.T) {
+			i := &IssueScheme{
+				ID:          testCase.fields.ID,
+				Key:         testCase.fields.Key,
+				Self:        testCase.fields.Self,
+				Transitions: testCase.fields.Transitions,
+				Changelog:   testCase.fields.Changelog,
+				Fields:      testCase.fields.Fields,
+			}
+			got, err := i.ToMap()
+
+			if (err != nil) != testCase.wantErr {
+				t.Errorf("ToMap() error = %v, wantErr %v", err, testCase.wantErr)
+				return
+			}
+			if !reflect.DeepEqual(got, testCase.want) {
+				t.Errorf("ToMap() got = %v, want %v", got, testCase.want)
+			}
+
+			if !reflect.DeepEqual(err, testCase.Err) {
+				t.Errorf("ToMap() got = (%v), want (%v)", err, testCase.Err)
+			}
+		})
+	}
+}