Files
coder/enterprise/cli/features_test.go
T
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

57 lines
1.5 KiB
Go

package cli_test
import (
"bytes"
"encoding/json"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/coder/coder/v2/cli/clitest"
"github.com/coder/coder/v2/codersdk"
"github.com/coder/coder/v2/enterprise/coderd/coderdenttest"
"github.com/coder/coder/v2/pty/ptytest"
)
func TestFeaturesList(t *testing.T) {
t.Parallel()
t.Run("Table", func(t *testing.T) {
t.Parallel()
client, _ := coderdenttest.New(t, &coderdenttest.Options{DontAddLicense: true})
inv, conf := newCLI(t, "features", "list")
clitest.SetupConfig(t, client, conf)
pty := ptytest.New(t).Attach(inv)
clitest.Start(t, inv)
pty.ExpectMatch("user_limit")
pty.ExpectMatch("not_entitled")
})
t.Run("JSON", func(t *testing.T) {
t.Parallel()
client, _ := coderdenttest.New(t, &coderdenttest.Options{DontAddLicense: true})
inv, conf := newCLI(t, "features", "list", "-o", "json")
clitest.SetupConfig(t, client, conf)
doneChan := make(chan struct{})
buf := bytes.NewBuffer(nil)
inv.Stdout = buf
go func() {
defer close(doneChan)
err := inv.Run()
assert.NoError(t, err)
}()
<-doneChan
var entitlements codersdk.Entitlements
err := json.Unmarshal(buf.Bytes(), &entitlements)
require.NoError(t, err, "unmarshal JSON output")
assert.Empty(t, entitlements.Warnings)
for _, featureName := range codersdk.FeatureNames {
assert.Equal(t, codersdk.EntitlementNotEntitled, entitlements.Features[featureName].Entitlement)
}
assert.False(t, entitlements.HasLicense)
})
}