Skip to content

Commit

Permalink
switch to use blackbox testing, move tests to separate module
Browse files Browse the repository at this point in the history
This allows us to remove the test-dependencies from the module itself

Signed-off-by: Sebastiaan van Stijn <[email protected]>
  • Loading branch information
thaJeztah committed Dec 5, 2022
1 parent 1aeaba8 commit a5b1cb2
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 8 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3
- name: Test
run: go test -v ./...
run: cd test && go test -v .
lint:
runs-on: ubuntu-latest
steps:
Expand All @@ -26,3 +26,8 @@ jobs:
docker run --rm -v `pwd`:/go/src/github.com/moby/term -w /go/src/github.com/moby/term \
golangci/golangci-lint:v1.50.1 golangci-lint run --disable-all -v \
-E govet -E misspell -E gofmt -E ineffassign -E revive
- name: Lint tests
run: |
docker run --rm -v `pwd`:/go/src/github.com/moby/term -w /go/src/github.com/moby/term/test \
golangci/golangci-lint:v1.50.1 golangci-lint run --disable-all -v \
-E govet -E misspell -E gofmt -E ineffassign -E revive
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ go 1.18

require (
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1
github.com/creack/pty v1.1.18
golang.org/x/sys v0.1.0
)
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8=
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY=
github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
15 changes: 15 additions & 0 deletions test/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module github.com/moby/term/test

go 1.18

require (
github.com/creack/pty v1.1.18
github.com/moby/term v0.0.0-00010101000000-000000000000 // replaced
)

require (
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
golang.org/x/sys v0.1.0 // indirect
)

replace github.com/moby/term => ../
7 changes: 7 additions & 0 deletions test/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8=
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY=
github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
4 changes: 3 additions & 1 deletion proxy_test.go → test/proxy_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package term
package test

import (
"bytes"
"testing"

. "github.com/moby/term"
)

func TestEscapeProxyRead(t *testing.T) {
Expand Down
7 changes: 4 additions & 3 deletions term_test.go → test/term_test.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
//go:build !windows
// +build !windows

package term
package test

import (
"os"
"reflect"
"testing"

cpty "github.com/creack/pty"
. "github.com/moby/term"
)

func newTTYForTest(t *testing.T) *os.File {
Expand Down Expand Up @@ -47,7 +48,7 @@ func TestGetWinsize(t *testing.T) {
t.Fatal("winSize is nil")
}

newSize := Winsize{Width: 200, Height: 200, x: winSize.x, y: winSize.y}
newSize := Winsize{Width: 200, Height: 200}
err = SetWinsize(tty.Fd(), &newSize)
if err != nil {
t.Fatal(err)
Expand All @@ -70,7 +71,7 @@ func TestSetWinsize(t *testing.T) {
if winSize == nil {
t.Fatal("winSize is nil")
}
newSize := Winsize{Width: 200, Height: 200, x: winSize.x, y: winSize.y}
newSize := Winsize{Width: 200, Height: 200}
err = SetWinsize(tty.Fd(), &newSize)
if err != nil {
t.Fatal(err)
Expand Down

0 comments on commit a5b1cb2

Please sign in to comment.