Skip to content

Commit 1138c77

Browse files
Merge pull request #17 from luchihoratiu/CT-190
(CT-190) Move output to stdout instead of stderr
2 parents bb2967b + f768b9a commit 1138c77

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

app/puppet-code/deploy.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package app
33
import (
44
"context"
55
"fmt"
6-
"os"
76

87
httptransport "github.com/go-openapi/runtime/client"
98
"github.com/puppetlabs/pe-sdk-go/app/puppet-code/api/client/operations"
@@ -64,8 +63,6 @@ type DeployArgs struct {
6463
}
6564

6665
func writeDeployResult(args *DeployArgs, payload []*operations.DeployOKBodyItems0) []byte {
67-
fmt.Fprintf(os.Stderr, "Found %d environments.\n", len(payload))
68-
6966
if args.DryRun {
7067
separator := ""
7168
environments := ""
@@ -79,5 +76,7 @@ func writeDeployResult(args *DeployArgs, payload []*operations.DeployOKBodyItems
7976
if err != nil {
8077
log.Error(err.Error())
8178
}
82-
return resultPayload
79+
80+
info := []byte(fmt.Sprintf("Found %d environments.\n", len(payload)))
81+
return append(info, resultPayload...)
8382
}

app/puppet-code/deploy_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package app
33
import (
44
"context"
55
"errors"
6+
"fmt"
67
"testing"
78

89
"github.com/golang/mock/gomock"
@@ -81,7 +82,8 @@ func TestDeployStatusSucces(t *testing.T) {
8182
puppetCode.Client = api
8283
res, err := puppetCode.DeployWithErrorDetails(&args)
8384
expected, _ := json.MarshalIndent(result.Payload, "", " ")
84-
assert.Equal(expected, res)
85+
info := []byte(fmt.Sprintf("Found %d environments.\n", 0))
86+
assert.Equal(append(info, expected...), res)
8587
assert.Nil(err)
8688
}
8789

0 commit comments

Comments
 (0)