Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
dsa0x committed Oct 17, 2024
1 parent 3732a3b commit ed36a7a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
1 change: 0 additions & 1 deletion registry_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,6 @@ func (r *registryModules) Read(ctx context.Context, moduleID RegistryModuleID) (
if moduleID.ExternalID != "" {
u = fmt.Sprintf("registry-modules/%s", url.PathEscape(moduleID.ExternalID))
} else {

if moduleID.RegistryName == "" {
log.Println("[WARN] Support for using the RegistryModuleID without RegistryName is deprecated as of release 1.5.0 and may be removed in a future version. The preferred method is to include the RegistryName in RegistryModuleID.")
moduleID.RegistryName = PrivateRegistry
Expand Down
21 changes: 21 additions & 0 deletions registry_module_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1193,6 +1193,27 @@ func TestRegistryModulesRead(t *testing.T) {
})
})

t.Run("with a external ID field for private module", func(t *testing.T) {
rm, err := client.RegistryModules.Read(ctx, RegistryModuleID{
ExternalID: registryModuleTest.ID,
})
require.NoError(t, err)
require.NotEmpty(t, rm)
assert.Equal(t, registryModuleTest.ID, rm.ID)

t.Run("permissions are properly decoded", func(t *testing.T) {
require.NotEmpty(t, rm.Permissions)
assert.True(t, rm.Permissions.CanDelete)
assert.True(t, rm.Permissions.CanResync)
assert.True(t, rm.Permissions.CanRetry)
})

t.Run("timestamps are properly decoded", func(t *testing.T) {
assert.NotEmpty(t, rm.CreatedAt)
assert.NotEmpty(t, rm.UpdatedAt)
})
})

t.Run("without a name", func(t *testing.T) {
rm, err := client.RegistryModules.Read(ctx, RegistryModuleID{
Organization: orgTest.Name,
Expand Down

0 comments on commit ed36a7a

Please sign in to comment.