Files
coder/scaletest/reconnectingpty/config_test.go
Kyle Carberry 22e781eced chore: add /v2 to import module path (#9072)
* chore: add /v2 to import module path

go mod requires semantic versioning with versions greater than 1.x

This was a mechanical update by running:
```
go install github.com/marwan-at-work/mod/cmd/mod@latest
mod upgrade
```

Migrate generated files to import /v2

* Fix gen
2023-08-18 18:55:43 +00:00

79 lines
1.5 KiB
Go

package reconnectingpty_test
import (
"testing"
"time"
"github.com/google/uuid"
"github.com/stretchr/testify/require"
"github.com/coder/coder/v2/coderd/httpapi"
"github.com/coder/coder/v2/codersdk"
"github.com/coder/coder/v2/scaletest/reconnectingpty"
)
func Test_Config(t *testing.T) {
t.Parallel()
id := uuid.New()
cases := []struct {
name string
config reconnectingpty.Config
errContains string
}{
{
name: "OKBasic",
config: reconnectingpty.Config{
AgentID: id,
},
},
{
name: "OKFull",
config: reconnectingpty.Config{
AgentID: id,
Init: codersdk.WorkspaceAgentReconnectingPTYInit{
ID: id,
Width: 80,
Height: 24,
Command: "echo 'hello world'",
},
Timeout: httpapi.Duration(time.Minute),
ExpectTimeout: false,
ExpectOutput: "hello world",
LogOutput: true,
},
},
{
name: "NoAgentID",
config: reconnectingpty.Config{
AgentID: uuid.Nil,
},
errContains: "agent_id must be set",
},
{
name: "NegativeTimeout",
config: reconnectingpty.Config{
AgentID: id,
Timeout: httpapi.Duration(-time.Minute),
},
errContains: "timeout must be a positive value",
},
}
for _, c := range cases {
c := c
t.Run(c.name, func(t *testing.T) {
t.Parallel()
err := c.config.Validate()
if c.errContains != "" {
require.Error(t, err)
require.Contains(t, err.Error(), c.errContains)
} else {
require.NoError(t, err)
}
})
}
}