Skip to content

Commit

Permalink
add a test to check it returns an error when the matching project is …
Browse files Browse the repository at this point in the history
…not found
  • Loading branch information
grezar committed Dec 22, 2021
1 parent 368f6d0 commit f306133
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions provider/to/circleci/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package circleci

import (
"context"
"errors"
"testing"

"github.com/golang/mock/gomock"
Expand Down Expand Up @@ -183,6 +184,33 @@ func TestSpec_UpdateProjectVariables(t *testing.T) {
},
},
},
{
name: "It returns an error when the matching project is not found",
fields: fields{
Owner: "org1",
ProjectVariables: []*ProjectVariable{
{
Project: "prj1",
Variables: []*Variable{
{
Name: "SECRET1",
Value: "111",
},
},
},
},
Projects: func(t *testing.T, ctrl *gomock.Controller) *mock.MockProjects {
t.Helper()

ctx := context.Background()
project := "prj1"
mock := mock.NewMockProjects(ctrl)
mock.EXPECT().ListVariables(ctx, project).Return(nil, errors.New("project is not found"))
return mock
},
},
wantErr: true,
},
{
name: "Met conditions for updating project variables but doesn't do destructive changes in dry-run mode",
fields: fields{
Expand Down

0 comments on commit f306133

Please sign in to comment.