File: activeterm_test.go

package info (click to toggle)
golang-github-charmbracelet-wish 0.1.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 164 kB
  • sloc: makefile: 3
file content (28 lines) | stat: -rw-r--r-- 618 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package activeterm_test

import (
	"testing"

	"github.com/charmbracelet/wish/activeterm"
	"github.com/charmbracelet/wish/testsession"
	"github.com/gliderlabs/ssh"
	gossh "golang.org/x/crypto/ssh"
)

func TestMiddleware(t *testing.T) {
	t.Run("inactive term", func(t *testing.T) {
		if err := setup(t).Run(""); err == nil {
			t.Errorf("tests should be an inactive pty")
		}
	})
}

func setup(t *testing.T) *gossh.Session {
	session, _, cleanup := testsession.New(t, &ssh.Server{
		Handler: activeterm.Middleware()(func(s ssh.Session) {
			s.Write([]byte("hello"))
		}),
	}, nil)
	t.Cleanup(cleanup)
	return session
}