Commit 9efaef6
Changed files (2)
pkg
tasks
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)
+ })
+}
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)
+ })
+ })
+}