diff --git a/provider/to/circleci/provider_test.go b/provider/to/circleci/provider_test.go index 780b2ea..bd50677 100644 --- a/provider/to/circleci/provider_test.go +++ b/provider/to/circleci/provider_test.go @@ -2,6 +2,7 @@ package circleci import ( "context" + "errors" "testing" "github.com/golang/mock/gomock" @@ -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{