mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-08-09 15:32:46 -04:00
consistently use stdout and stderr (#502)
* consistently use stdout and stderr Signed-off-by: Fabian Kammel <fk@edgeless.systems>
This commit is contained in:
parent
e011c7ef78
commit
81a5907f26
14 changed files with 61 additions and 59 deletions
|
@ -21,6 +21,7 @@ import (
|
|||
"github.com/edgelesssys/constellation/v2/internal/constants"
|
||||
"github.com/edgelesssys/constellation/v2/internal/file"
|
||||
"github.com/spf13/afero"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"golang.org/x/mod/semver"
|
||||
|
@ -271,7 +272,7 @@ func TestGetCompatibleImageMeasurements(t *testing.T) {
|
|||
|
||||
pubK := []byte("-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEUs5fDUIz9aiwrfr8BK4VjN7jE6sl\ngz7UuXsOin8+dB0SGrbNHy7TJToa2fAiIKPVLTOfvY75DqRAtffhO1fpBA==\n-----END PUBLIC KEY-----")
|
||||
|
||||
err := getCompatibleImageMeasurements(context.Background(), client, singleUUIDVerifier(), pubK, testImages)
|
||||
err := getCompatibleImageMeasurements(context.Background(), &cobra.Command{}, client, singleUUIDVerifier(), pubK, testImages)
|
||||
assert.NoError(err)
|
||||
|
||||
for _, image := range testImages {
|
||||
|
@ -456,8 +457,10 @@ func TestUpgradePlan(t *testing.T) {
|
|||
|
||||
cmd := newUpgradePlanCmd()
|
||||
cmd.SetContext(context.Background())
|
||||
var out bytes.Buffer
|
||||
cmd.SetOut(&out)
|
||||
var outTarget bytes.Buffer
|
||||
cmd.SetOut(&outTarget)
|
||||
var errTarget bytes.Buffer
|
||||
cmd.SetErr(&errTarget)
|
||||
|
||||
client := newTestClient(func(req *http.Request) *http.Response {
|
||||
if req.URL.String() == imageReleaseURL {
|
||||
|
@ -497,13 +500,13 @@ func TestUpgradePlan(t *testing.T) {
|
|||
|
||||
assert.NoError(err)
|
||||
if !tc.wantUpgrade {
|
||||
assert.Contains(out.String(), "No compatible images")
|
||||
assert.Contains(errTarget.String(), "No compatible images")
|
||||
return
|
||||
}
|
||||
|
||||
var availableUpgrades map[string]config.UpgradeConfig
|
||||
if tc.flags.filePath == "-" {
|
||||
require.NoError(yaml.Unmarshal(out.Bytes(), &availableUpgrades))
|
||||
require.NoError(yaml.Unmarshal(outTarget.Bytes(), &availableUpgrades))
|
||||
} else {
|
||||
require.NoError(fileHandler.ReadYAMLStrict(tc.flags.filePath, &availableUpgrades))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue