Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/dev/preview/previewctl/pkg/ssh/mock.go
2501 views
1
// Copyright (c) 2022 Gitpod GmbH. All rights reserved.
2
// Licensed under the GNU Affero General Public License (AGPL).
3
// See License.AGPL.txt in the project root for license information.
4
5
package ssh
6
7
import (
8
"context"
9
"io"
10
11
"github.com/cockroachdb/errors"
12
)
13
14
var _ Client = &MockClient{}
15
16
type MockCmd struct {
17
CMD string
18
STDOUT []byte
19
STDERR []byte
20
Err error
21
}
22
23
type MockClient struct {
24
Command MockCmd
25
}
26
27
func (m MockClient) Close() error {
28
return nil
29
}
30
31
func (m MockClient) Run(ctx context.Context, cmd string, stdout io.Writer, stderr io.Writer) error {
32
if m.Command.CMD != cmd {
33
return errors.New("command not found")
34
}
35
36
_, _ = stdout.Write(m.Command.STDOUT)
37
_, _ = stderr.Write(m.Command.STDERR)
38
return m.Command.Err
39
}
40
41