github.com/ungtb10d/cli/v2@v2.0.0-20221110210412-98537dd9d6a1/internal/codespaces/grpc/test/session.go (about) 1 package test 2 3 import ( 4 "context" 5 "fmt" 6 "net" 7 8 "github.com/ungtb10d/cli/v2/pkg/liveshare" 9 "golang.org/x/crypto/ssh" 10 ) 11 12 type Session struct { 13 channel ssh.Channel 14 } 15 16 func (s *Session) KeepAlive(reason string) { 17 } 18 19 func (s *Session) StartSharing(ctx context.Context, sessionName string, port int) (liveshare.ChannelID, error) { 20 conn, err := net.Dial("tcp", fmt.Sprintf("127.0.0.1:%d", ServerPort)) 21 if err != nil { 22 return liveshare.ChannelID{}, err 23 } 24 s.channel = &Channel{conn} 25 return liveshare.ChannelID{}, nil 26 } 27 28 // Creates mock SSH channel connected to the mock gRPC server 29 func (s *Session) OpenStreamingChannel(ctx context.Context, id liveshare.ChannelID) (ssh.Channel, error) { 30 return s.channel, nil 31 }