Skip to content

Commit

Permalink
Merge pull request #177 from ctreminiom/feature/coverage-increase
Browse files Browse the repository at this point in the history
✅ Added the test-cases for the service declaration.
  • Loading branch information
ctreminiom authored Mar 12, 2023
2 parents 5f7242c + 0a4bf69 commit 87369df
Show file tree
Hide file tree
Showing 57 changed files with 4,109 additions and 74 deletions.
53 changes: 53 additions & 0 deletions jira/internal/application_role_impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,3 +362,56 @@ func TestApplicationRoleService_Gets(t *testing.T) {
})
}
}

func TestNewApplicationRoleService(t *testing.T) {

type args struct {
client service.Client
version string
}

testCases := []struct {
name string
args args
wantErr bool
err error
}{
{
name: "when the parameters are correct",
args: args{
client: nil,
version: "3",
},
wantErr: false,
},

{
name: "when the version is not provided",
args: args{
client: nil,
version: "",
},
wantErr: true,
err: model.ErrNoVersionProvided,
},
}
for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
got, err := NewApplicationRoleService(testCase.args.client, testCase.args.version)

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)
assert.NotEqual(t, got, nil)
}
})
}
}
53 changes: 53 additions & 0 deletions jira/internal/attachment_impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -919,3 +919,56 @@ func Test_internalIssueAttachmentServiceImpl_Download(t *testing.T) {
})
}
}

func TestNewIssueAttachmentService(t *testing.T) {

type args struct {
client service.Client
version string
}

testCases := []struct {
name string
args args
wantErr bool
err error
}{
{
name: "when the parameters are correct",
args: args{
client: nil,
version: "3",
},
wantErr: false,
},

{
name: "when the version is not provided",
args: args{
client: nil,
version: "",
},
wantErr: true,
err: model.ErrNoVersionProvided,
},
}
for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
got, err := NewIssueAttachmentService(testCase.args.client, testCase.args.version)

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)
assert.NotEqual(t, got, nil)
}
})
}
}
52 changes: 38 additions & 14 deletions jira/internal/dashboard_impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ import (
"errors"
model "github.com/ctreminiom/go-atlassian/pkg/infra/models"
"github.com/ctreminiom/go-atlassian/service"
"github.com/ctreminiom/go-atlassian/service/jira"
"github.com/ctreminiom/go-atlassian/service/mocks"
"github.com/stretchr/testify/assert"
"net/http"
"reflect"
"testing"
)

Expand Down Expand Up @@ -1173,27 +1171,53 @@ func TestDashboardService_Delete(t *testing.T) {
}

func TestNewDashboardService(t *testing.T) {

type args struct {
client service.Client
version string
}
tests := []struct {

testCases := []struct {
name string
args args
want jira.DashboardConnector
wantErr bool
err error
}{
// TODO: Add test cases.
{
name: "when the parameters are correct",
args: args{
client: nil,
version: "3",
},
wantErr: false,
},

{
name: "when the version is not provided",
args: args{
client: nil,
version: "",
},
wantErr: true,
err: model.ErrNoVersionProvided,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := NewDashboardService(tt.args.client, tt.args.version)
if (err != nil) != tt.wantErr {
t.Errorf("NewDashboardService() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("NewDashboardService() got = %v, want %v", got, tt.want)
for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
got, err := NewDashboardService(testCase.args.client, testCase.args.version)

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)
assert.NotEqual(t, got, nil)
}
})
}
Expand Down
53 changes: 53 additions & 0 deletions jira/internal/field_configuration_impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -682,3 +682,56 @@ func Test_internalIssueFieldConfigServiceImpl_Delete(t *testing.T) {
})
}
}

func TestNewIssueFieldConfigurationService(t *testing.T) {

type args struct {
client service.Client
version string
}

testCases := []struct {
name string
args args
wantErr bool
err error
}{
{
name: "when the parameters are correct",
args: args{
client: nil,
version: "3",
},
wantErr: false,
},

{
name: "when the version is not provided",
args: args{
client: nil,
version: "",
},
wantErr: true,
err: model.ErrNoVersionProvided,
},
}
for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
got, err := NewIssueFieldConfigurationService(testCase.args.client, testCase.args.version, nil, nil)

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)
assert.NotEqual(t, got, nil)
}
})
}
}
53 changes: 53 additions & 0 deletions jira/internal/field_configuration_item_impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,3 +443,56 @@ func Test_internalIssueFieldConfigItemServiceImpl_Update(t *testing.T) {
})
}
}

func Test_NewIssueFieldConfigurationItemService(t *testing.T) {

type args struct {
client service.Client
version string
}

testCases := []struct {
name string
args args
wantErr bool
err error
}{
{
name: "when the parameters are correct",
args: args{
client: nil,
version: "3",
},
wantErr: false,
},

{
name: "when the version is not provided",
args: args{
client: nil,
version: "",
},
wantErr: true,
err: model.ErrNoVersionProvided,
},
}
for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
got, err := NewIssueFieldConfigurationItemService(testCase.args.client, testCase.args.version)

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)
assert.NotEqual(t, got, nil)
}
})
}
}
53 changes: 53 additions & 0 deletions jira/internal/field_configuration_scheme_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1460,3 +1460,56 @@ func Test_internalIssueFieldConfigSchemeServiceImpl_Unlink(t *testing.T) {
})
}
}

func Test_NewIssueFieldConfigurationSchemeService(t *testing.T) {

type args struct {
client service.Client
version string
}

testCases := []struct {
name string
args args
wantErr bool
err error
}{
{
name: "when the parameters are correct",
args: args{
client: nil,
version: "3",
},
wantErr: false,
},

{
name: "when the version is not provided",
args: args{
client: nil,
version: "",
},
wantErr: true,
err: model.ErrNoVersionProvided,
},
}
for _, testCase := range testCases {
t.Run(testCase.name, func(t *testing.T) {
got, err := NewIssueFieldConfigurationSchemeService(testCase.args.client, testCase.args.version)

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)
assert.NotEqual(t, got, nil)
}
})
}
}
Loading

0 comments on commit 87369df

Please sign in to comment.