Skip to content

Commit 532a671

Browse files
author
Mate Herber
authored
Revert forced v2 migration (#72)
* Revert forced v2 migration * Fix errors
1 parent aec3fd2 commit 532a671

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1922
-1346
lines changed

cachedcarthage/mockCarthage_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package cachedcarthage
22

3-
import mock "github.com/stretchr/testify/mock"
3+
import "github.com/stretchr/testify/mock"
44

55
// MockCarthageCache is an autogenerated mock type for the CarthageCache type
66
type MockCarthageCache struct {
Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
11
package cachedcarthage
22

33
import (
4-
"github.com/bitrise-io/go-utils/env"
5-
"github.com/stretchr/testify/mock"
6-
"io"
7-
84
"github.com/bitrise-io/go-steputils/stepconf"
95
"github.com/bitrise-io/go-utils/command"
6+
"github.com/stretchr/testify/mock"
107
)
118

12-
type CommandBlueprint struct {
13-
Command string
14-
Arguments []string
15-
}
16-
179
// MockCommandBuilder is an autogenerated mock type for the CommandBuilder type
1810
type MockCommandBuilder struct {
1911
mock.Mock
@@ -38,9 +30,9 @@ func (m *MockCommandBuilder) Append(args ...string) CommandBuilder {
3830
}
3931

4032
// Command provides a mock function with given fields:
41-
func (m *MockCommandBuilder) Command(stdout io.Writer, stderr io.Writer) command.Command {
42-
args := m.Called(stdout, stderr)
43-
return args.Get(0).(command.Command)
33+
func (m *MockCommandBuilder) Command() *command.Model {
34+
args := m.Called()
35+
return args.Get(0).(*command.Model)
4436
}
4537

4638
func (m *MockCommandBuilder) GivenAddGitHubTokenSucceeds() *MockCommandBuilder {
@@ -58,27 +50,17 @@ func (m *MockCommandBuilder) GivenAppendSucceeds() *MockCommandBuilder {
5850
return m
5951
}
6052

61-
func (m *MockCommandBuilder) GivenCommandReturned(blueprint CommandBlueprint) *MockCommandBuilder {
62-
command := command.NewFactory(env.NewRepository()).Create(blueprint.Command, blueprint.Arguments, nil)
63-
64-
m.On("Command", mock.Anything, mock.Anything).Return(command)
53+
func (m *MockCommandBuilder) GivenCommandReturned(command *command.Model) *MockCommandBuilder {
54+
m.On("Command").Return(command)
6555
return m
6656
}
6757

68-
func (m *MockCommandBuilder) GivenCommandsReturned(commandBlueprints []CommandBlueprint) *MockCommandBuilder {
58+
func (m *MockCommandBuilder) GivenCommandsReturned(commands []*command.Model) *MockCommandBuilder {
6959
index := 0
70-
71-
call := m.On("Command", mock.Anything, mock.Anything)
60+
call := m.On("Command")
7261
call.RunFn = func(args mock.Arguments) {
73-
blueprint := commandBlueprints[index]
74-
command := command.NewFactory(env.NewRepository()).Create(blueprint.Command, blueprint.Arguments, &command.Opts{
75-
Stdout: args[0].(io.Writer),
76-
Stderr: args[1].(io.Writer),
77-
})
78-
call.ReturnArguments = mock.Arguments{command, nil}
79-
62+
call.ReturnArguments = mock.Arguments{commands[index], nil}
8063
index++
8164
}
82-
8365
return m
8466
}

cachedcarthage/mockFileCache_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package cachedcarthage
22

3-
import mock "github.com/stretchr/testify/mock"
3+
import "github.com/stretchr/testify/mock"
44

55
// MockFileCache is an autogenerated mock type for the FileCache type
66
type MockFileCache struct {

cachedcarthage/mockProjectStateProvider_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package cachedcarthage
22

3-
import mock "github.com/stretchr/testify/mock"
3+
import "github.com/stretchr/testify/mock"
44

55
// MockProjectStateProvider is an autogenerated mock type for the ProjectStateProvider type
66
type MockProjectStateProvider struct {

cachedcarthage/runner.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type CommandBuilder interface {
3030
AddGitHubToken(githubToken stepconf.Secret) CommandBuilder
3131
AddXCConfigFile(path string) CommandBuilder
3232
Append(args ...string) CommandBuilder
33-
Command(stdout io.Writer, stderr io.Writer) command.Command
33+
Command() *command.Model
3434
}
3535

3636
// Runner can be used to execute Carthage command and cache the results.
@@ -145,7 +145,9 @@ func (runner Runner) executeCommand() error {
145145
Append(runner.args...)
146146
var stderrBuf bytes.Buffer
147147

148-
cmd := builder.Command(os.Stdout, io.MultiWriter(os.Stderr, &stderrBuf))
148+
cmd := builder.Command()
149+
cmd.SetStdout(os.Stdout)
150+
cmd.SetStderr(io.MultiWriter(os.Stderr, &stderrBuf))
149151

150152
log.Donef("$ %s", cmd.PrintableCommandArgs())
151153

cachedcarthage/runner_error.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ func hasRetryableFailure(err error) bool {
3030
if errors.As(err, &runnerError) {
3131
output := strings.ToLower(runnerError.Output)
3232

33-
for _, string := range getErrorSlices(){
34-
if strings.Contains(output, string) {
33+
for _, str := range getErrorSlices(){
34+
if strings.Contains(output, str) {
3535
return true
3636
}
3737
}

0 commit comments

Comments
 (0)