diff options
| -rw-r--r-- | pkg/tasks/create_client_test.go | 23 | ||||
| -rw-r--r-- | pkg/x/must_test.go | 24 |
2 files changed, 47 insertions, 0 deletions
diff --git a/pkg/tasks/create_client_test.go b/pkg/tasks/create_client_test.go new file mode 100644 index 0000000..854a20d --- /dev/null +++ b/pkg/tasks/create_client_test.go @@ -0,0 +1,23 @@ +package tasks + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "mokhan.ca/xlgmokha/idp/pkg/dto" +) + +func TestCreateClient(t *testing.T) { + t.Run("with valid parameters", func(t *testing.T) { + request := dto.ClientRegistrationRequest{ + ClientMetadata: dto.ClientMetadata{ + ClientName: "jive", + RedirectUris: []string{"https://example.com/callback"}, + }, + } + response, err := CreateClient(request) + + assert.Nil(t, err) + assert.NotNil(t, response) + }) +} diff --git a/pkg/x/must_test.go b/pkg/x/must_test.go new file mode 100644 index 0000000..a571beb --- /dev/null +++ b/pkg/x/must_test.go @@ -0,0 +1,24 @@ +package x + +import ( + "errors" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestMust(t *testing.T) { + t.Run("without error", func(t *testing.T) { + item := 1 + result := Must(item, nil) + assert.Equal(t, item, result) + }) + + t.Run("with error", func(t *testing.T) { + assert.Panics(t, func() { + item := 1 + result := Must(item, errors.New("darn")) + assert.Equal(t, item, result) + }) + }) +} |
