-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Miscellaneous test coverage improvements (#719)
Co-authored-by: Will Vedder <[email protected]> Co-authored-by: Sergiu Ghitea <[email protected]>
- Loading branch information
1 parent
437ce7d
commit ac090d1
Showing
14 changed files
with
256 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package display | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/auth0/go-auth0/management" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestGetScopes(t *testing.T) { | ||
t.Run("no scopes should not truncate", func(t *testing.T) { | ||
mockScopes := []management.ResourceServerScope{} | ||
|
||
scopes, didTruncate := getScopes(mockScopes) | ||
assert.Equal(t, "", scopes) | ||
assert.False(t, didTruncate) | ||
}) | ||
|
||
t.Run("few scopes should not truncate", func(t *testing.T) { | ||
mockScopes := []management.ResourceServerScope{} | ||
|
||
for i := 0; i < 3; i++ { | ||
v := fmt.Sprintf("scope%d", i) | ||
d := fmt.Sprintf("Description for scope%d", i) | ||
|
||
mockScopes = append(mockScopes, management.ResourceServerScope{ | ||
Value: &v, | ||
Description: &d, | ||
}) | ||
} | ||
|
||
scopes, didTruncate := getScopes(mockScopes) | ||
assert.Equal(t, "scope0 scope1 scope2", scopes) | ||
assert.False(t, didTruncate) | ||
}) | ||
|
||
t.Run("should truncate", func(t *testing.T) { | ||
mockScopes := []management.ResourceServerScope{} | ||
|
||
for i := 0; i < 100; i++ { | ||
v := fmt.Sprintf("scope%d", i) | ||
d := fmt.Sprintf("Description for scope%d", i) | ||
|
||
mockScopes = append(mockScopes, management.ResourceServerScope{ | ||
Value: &v, | ||
Description: &d, | ||
}) | ||
} | ||
|
||
scopes, didTruncate := getScopes(mockScopes) | ||
assert.Equal(t, "scope0 scope1 scope2 scope3 scope4 scope5 scope6...", scopes) | ||
assert.True(t, didTruncate) | ||
}) | ||
} | ||
|
||
func TestApiView_AsTableHeader(t *testing.T) { | ||
mockAPIView := apiView{} | ||
assert.Equal(t, []string{}, mockAPIView.AsTableHeader()) | ||
} | ||
|
||
func TestApiView_AsTableRow(t *testing.T) { | ||
mockAPIView := apiView{} | ||
assert.Equal(t, []string{}, mockAPIView.AsTableRow()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package display | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestCustomDomainView_AsTableHeader(t *testing.T) { | ||
mockCustomDomainView := customDomainView{} | ||
|
||
assert.Equal(t, []string{"ID", "Domain", "Status"}, mockCustomDomainView.AsTableHeader()) | ||
} | ||
|
||
func TestCustomDomainView_AsTableRow(t *testing.T) { | ||
mockCustomDomainView := customDomainView{ | ||
ID: "custom-domain-id", | ||
Domain: "example.com", | ||
Status: "verified", | ||
} | ||
|
||
assert.Equal(t, []string{"custom-domain-id", "example.com", "verified"}, mockCustomDomainView.AsTableRow()) | ||
} |
Oops, something went wrong.