mirror of
https://github.com/coder/coder.git
synced 2025-07-13 21:36:50 +00:00
Feature server implementation (#3899)
* Feature server implementation Signed-off-by: Spike Curtis <spike@coder.com> * Fix imports Signed-off-by: Spike Curtis <spike@coder.com> Signed-off-by: Spike Curtis <spike@coder.com>
This commit is contained in:
@ -9,6 +9,7 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/coder/coder/coderd/audit"
|
||||
"github.com/coder/coder/codersdk"
|
||||
)
|
||||
|
||||
@ -36,3 +37,64 @@ func TestEntitlements(t *testing.T) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestFeaturesServiceGet(t *testing.T) {
|
||||
t.Parallel()
|
||||
t.Run("Auditor", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
uut := featuresService{}
|
||||
target := struct {
|
||||
Auditor audit.Auditor
|
||||
}{}
|
||||
err := uut.Get(&target)
|
||||
require.NoError(t, err)
|
||||
assert.NotNil(t, target.Auditor)
|
||||
})
|
||||
|
||||
t.Run("NotPointer", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
uut := featuresService{}
|
||||
target := struct {
|
||||
Auditor audit.Auditor
|
||||
}{}
|
||||
err := uut.Get(target)
|
||||
require.Error(t, err)
|
||||
assert.Nil(t, target.Auditor)
|
||||
})
|
||||
|
||||
t.Run("UnknownInterface", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
uut := featuresService{}
|
||||
target := struct {
|
||||
test testInterface
|
||||
}{}
|
||||
err := uut.Get(&target)
|
||||
require.Error(t, err)
|
||||
assert.Nil(t, target.test)
|
||||
})
|
||||
|
||||
t.Run("PointerToNonStruct", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
uut := featuresService{}
|
||||
var target audit.Auditor
|
||||
err := uut.Get(&target)
|
||||
require.Error(t, err)
|
||||
assert.Nil(t, target)
|
||||
})
|
||||
|
||||
t.Run("StructWithNonInterfaces", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
uut := featuresService{}
|
||||
target := struct {
|
||||
N int64
|
||||
Auditor audit.Auditor
|
||||
}{}
|
||||
err := uut.Get(&target)
|
||||
require.Error(t, err)
|
||||
assert.Nil(t, target.Auditor)
|
||||
})
|
||||
}
|
||||
|
||||
type testInterface interface {
|
||||
Test() error
|
||||
}
|
||||
|
Reference in New Issue
Block a user