Skip to content

Commit

Permalink
Clean up.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnbdz committed Oct 26, 2024
1 parent 3abc8de commit 235a2e3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
6 changes: 3 additions & 3 deletions entity/build/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ func TestMeta(t *testing.T) {
hasError bool
}{
// FIXME:
/*{
{
name: "Valid Entity URI Without Version",
inputPaths: storage.AbsPaths{
Entities: "testdata",
},
inputEntityUri: "github.com/example/entity",
internalEntityDir: "testdata/entity_remote.txt",
mockValidation: func(mockValidation *validation.MockEntityValidation) {
mockValidation.EXPECT().EntityUri("https://github.com/example/entity").Return(true)
mockValidation.EXPECT().EntityUri("github.com/example/entity").Return(true)
},
mockEntityVersion: func(mockEntityVersion *version.MockEntityVersion) {
mockEntityVersion.EXPECT().List("https://github.com/example/entity").Return([]string{"v1.0.0"}, nil)
Expand All @@ -66,7 +66,7 @@ func TestMeta(t *testing.T) {
Exist: true,
},
hasError: false,
},*/
},
//
// Error
//
Expand Down
12 changes: 5 additions & 7 deletions entity/entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ type IEntity interface {

// SEntity used for mock
type SEntity struct {
EntityVersion version.IVersion
EntityVersion version.IVersion
EntityVersionValidation versionValidationPkg.IValidation

// Data
Entities []Entity
Expand Down Expand Up @@ -124,8 +125,7 @@ func (s *SEntity) GetEntity(entityUri string) (Entity, error) {

// FindEntityDir can find pseudo versioned entity directories and static versioned entities.
func (s *SEntity) FindEntityDir(paths storage.AbsPaths, entityVals Entity) (string, error) {
entityVersionValidation := versionValidationPkg.NewEntityVersionValidationService()
if !entityVersionValidation.PseudoFormat(entityVals.Version) {
if !s.EntityVersionValidation.PseudoFormat(entityVals.Version) {
exactPath := entityVals.Entity

// Check if the directory exists
Expand Down Expand Up @@ -169,13 +169,11 @@ func (s *SEntity) FindEntityDir(paths storage.AbsPaths, entityVals Entity) (stri

// CheckDuplicateEntity checks if entityMeta is already in entityBuilds.
func (s *SEntity) CheckDuplicateEntity(entities []Entity, entityMeta Entity) error {
entityVersionValidation := versionValidationPkg.NewEntityVersionValidationService()

for _, existingEntity := range entities {
if existingEntity.Origin == entityMeta.Origin &&
existingEntity.Name == entityMeta.Name {
if entityVersionValidation.PseudoFormat(existingEntity.Version) &&
entityVersionValidation.PseudoFormat(entityMeta.Version) {
if s.EntityVersionValidation.PseudoFormat(existingEntity.Version) &&
s.EntityVersionValidation.PseudoFormat(entityMeta.Version) {
// Check pseudo versions
if s.GeneratePseudoVersionPattern(existingEntity.Name, existingEntity.Version) ==
s.GeneratePseudoVersionPattern(entityMeta.Name, entityMeta.Version) {
Expand Down
8 changes: 6 additions & 2 deletions entity/service.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package entity

import "github.com/AmadlaOrg/hery/entity/version"
import (
"github.com/AmadlaOrg/hery/entity/version"
versionValidationPkg "github.com/AmadlaOrg/hery/entity/version/validation"
)

// NewEntityService to set up the entity build service
func NewEntityService() *SEntity {
return &SEntity{
EntityVersion: version.NewEntityVersionService(),
EntityVersion: version.NewEntityVersionService(),
EntityVersionValidation: versionValidationPkg.NewEntityVersionValidationService(),

// Data
Entities: []Entity{},
Expand Down

0 comments on commit 235a2e3

Please sign in to comment.