Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lucassabreu committed Feb 15, 2024
1 parent b464f37 commit 7f4ef61
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 42 deletions.
32 changes: 14 additions & 18 deletions pkg/cmd/task/add/add_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@ func TestCmdAdd(t *testing.T) {
f.On("GetWorkspaceID").
Return("w", nil)

cf := mocks.NewMockConfig(t)
f.On("Config").Return(cf)
cf.On("IsAllowNameForID").Return(false)
f.EXPECT().Config().Return(&mocks.SimpleConfig{})

f.On("Client").Return(nil, errors.New("client error"))
return f
Expand Down Expand Up @@ -115,9 +113,9 @@ func TestCmdAdd(t *testing.T) {
Return("w", nil)
f.On("Client").Return(c, nil)

cf := mocks.NewMockConfig(t)
f.On("Config").Return(cf)
cf.On("IsAllowNameForID").Return(true)
f.EXPECT().Config().Return(&mocks.SimpleConfig{
AllowNameForID: true,
})

c.On("GetProjects", api.GetProjectsParam{
Workspace: "w",
Expand All @@ -138,9 +136,9 @@ func TestCmdAdd(t *testing.T) {
Return("w", nil)
f.On("Client").Return(c, nil)

cf := mocks.NewMockConfig(t)
f.On("Config").Return(cf)
cf.On("IsAllowNameForID").Return(true)
f.EXPECT().Config().Return(&mocks.SimpleConfig{
AllowNameForID: true,
})

c.On("GetProjects", api.GetProjectsParam{
Workspace: "w",
Expand Down Expand Up @@ -168,9 +166,7 @@ func TestCmdAdd(t *testing.T) {
Return("w", nil)
f.On("Client").Return(c, nil)

cf := mocks.NewMockConfig(t)
f.On("Config").Return(cf)
cf.On("IsAllowNameForID").Return(false)
f.EXPECT().Config().Return(&mocks.SimpleConfig{})

c.On("AddTask", api.AddTaskParam{
Workspace: "w",
Expand All @@ -196,9 +192,9 @@ func TestCmdAdd(t *testing.T) {
Return("w", nil)
f.On("Client").Return(c, nil)

cf := mocks.NewMockConfig(t)
f.On("Config").Return(cf)
cf.On("IsAllowNameForID").Return(true)
f.EXPECT().Config().Return(&mocks.SimpleConfig{
AllowNameForID: true,
})

c.On("GetProjects", api.GetProjectsParam{
Workspace: "w",
Expand Down Expand Up @@ -237,9 +233,9 @@ func TestCmdAdd(t *testing.T) {
Return("w", nil)
f.On("Client").Return(c, nil)

cf := mocks.NewMockConfig(t)
f.On("Config").Return(cf)
cf.On("IsAllowNameForID").Return(true)
f.EXPECT().Config().Return(&mocks.SimpleConfig{
AllowNameForID: true,
})

c.On("GetProjects", api.GetProjectsParam{
Workspace: "w",
Expand Down
28 changes: 13 additions & 15 deletions pkg/cmd/task/edit/edit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,7 @@ func TestCmdEdit(t *testing.T) {
f.On("GetWorkspaceID").
Return("w", nil)

cf := mocks.NewMockConfig(t)
f.On("Config").Return(cf)
cf.On("IsAllowNameForID").Return(false)
f.EXPECT().Config().Return(&mocks.SimpleConfig{})

f.On("Client").Return(nil, errors.New("client error"))
return f
Expand Down Expand Up @@ -147,9 +145,9 @@ func TestCmdEdit(t *testing.T) {
Return("w", nil)
f.On("Client").Return(c, nil)

cf := mocks.NewMockConfig(t)
f.On("Config").Return(cf)
cf.On("IsAllowNameForID").Return(true)
f.EXPECT().Config().Return(&mocks.SimpleConfig{
AllowNameForID: true,
})

c.On("GetProjects", api.GetProjectsParam{
Workspace: "w",
Expand Down Expand Up @@ -177,9 +175,9 @@ func TestCmdEdit(t *testing.T) {
Return("w", nil)
f.On("Client").Return(c, nil)

cf := mocks.NewMockConfig(t)
f.On("Config").Return(cf)
cf.On("IsAllowNameForID").Return(true)
f.EXPECT().Config().Return(&mocks.SimpleConfig{
AllowNameForID: true,
})

c.On("GetProjects", api.GetProjectsParam{
Workspace: "w",
Expand Down Expand Up @@ -239,9 +237,9 @@ func TestCmdEdit(t *testing.T) {
Return("w", nil)
f.On("Client").Return(c, nil)

cf := mocks.NewMockConfig(t)
f.On("Config").Return(cf)
cf.On("IsAllowNameForID").Return(true)
f.EXPECT().Config().Return(&mocks.SimpleConfig{
AllowNameForID: true,
})

c.On("GetProjects", api.GetProjectsParam{
Workspace: "w",
Expand Down Expand Up @@ -290,9 +288,9 @@ func TestCmdEdit(t *testing.T) {
Return("w", nil)
f.On("Client").Return(c, nil)

cf := mocks.NewMockConfig(t)
f.On("Config").Return(cf)
cf.On("IsAllowNameForID").Return(true)
f.EXPECT().Config().Return(&mocks.SimpleConfig{
AllowNameForID: true,
})

c.On("GetProjects", api.GetProjectsParam{
Workspace: "w",
Expand Down
12 changes: 6 additions & 6 deletions pkg/cmd/task/quick-add/quick-add_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ func TestCmdQuickAdd(t *testing.T) {
Return("w", nil)
f.EXPECT().Client().Return(c, nil)

cf := mocks.NewMockConfig(t)
f.EXPECT().Config().Return(cf)
cf.EXPECT().IsAllowNameForID().Return(true)
f.EXPECT().Config().Return(&mocks.SimpleConfig{
AllowNameForID: true,
})

c.EXPECT().GetProjects(api.GetProjectsParam{
Workspace: "w",
Expand Down Expand Up @@ -176,9 +176,9 @@ func TestCmdQuickAdd(t *testing.T) {
Return("w", nil)
f.EXPECT().Client().Return(c, nil)

cf := mocks.NewMockConfig(t)
f.EXPECT().Config().Return(cf)
cf.EXPECT().IsAllowNameForID().Return(true)
f.EXPECT().Config().Return(&mocks.SimpleConfig{
AllowNameForID: true,
})

c.EXPECT().GetProjects(api.GetProjectsParam{
Workspace: "w",
Expand Down
7 changes: 4 additions & 3 deletions pkg/cmd/time-entry/report/today/today_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ func TestCmdToday(t *testing.T) {
f := mocks.NewMockFactory(t)
f.On("GetUserID").Return("user-id", nil)
f.On("GetWorkspaceID").Return("w-id", nil)
f.EXPECT().Config().Return(&mocks.SimpleConfig{})

c := mocks.NewMockClient(t)
f.On("Client").Return(c, nil)
Expand Down Expand Up @@ -114,9 +115,9 @@ func TestCmdToday(t *testing.T) {
f.On("GetUserID").Return("user-id", nil)
f.On("GetWorkspaceID").Return("w-id", nil)

cf := mocks.NewMockConfig(t)
f.On("Config").Return(cf)
cf.On("IsAllowNameForID").Return(true)
f.EXPECT().Config().Return(&mocks.SimpleConfig{
AllowNameForID: true,
})

c := mocks.NewMockClient(t)
f.On("Client").Return(c, nil)
Expand Down

0 comments on commit 7f4ef61

Please sign in to comment.