Skip to content

Commit

Permalink
Some Test Written
Browse files Browse the repository at this point in the history
  • Loading branch information
keyurboss committed Dec 22, 2024
1 parent ea413fd commit 819199a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
1 change: 1 addition & 0 deletions src/interfaces/admin-user.entity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func TestAdminUserEntity(t *testing.T) {
if e.UserRolesInterface.Role != ROLE_ADMIN {
t.Fatalf("UserRolesInterface Role is not ROLE_ADMIN")
}
testBaseEntityCreateNewId(t, e.BaseEntity)
t.Run("password match", func(t *testing.T) {
if !e.MatchPassword("password") {
t.Fatalf("Password does not match")
Expand Down
36 changes: 21 additions & 15 deletions src/interfaces/base-entity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,36 @@ import (
"time"
)

func testBaseEntityCreateNewId(t *testing.T, c *BaseEntity) {

if c.ID == "" {
t.Fatalf("Id is empty")
}

if c.CreatedAt.IsZero() {
t.Fatalf("CreatedAt is empty")
}
if c.ModifiedAt.IsZero() {
t.Fatalf("ModifiedAt is empty")
}
if !c.CreatedAtExported.IsZero() {
t.Fatalf("CreatedAtExported is not empty %d", c.CreatedAtExported.Unix())
}
if !c.ModifiedAtExported.IsZero() {
t.Fatalf("ModifiedAtExported is not empty")
}
}

func TestBaseEntity(t *testing.T) {
c := &BaseEntity{}
c.createNewId()
t.Run("Create New ID", func(t *testing.T) {
id := c.ID
c.createNewId()
if c.ID == "" {
t.Fatalf("Id is empty")
}
if c.ID == id {
t.Fatalf("Id Should Be Different")
}
if c.CreatedAt.IsZero() {
t.Fatalf("CreatedAt is empty")
}
if c.ModifiedAt.IsZero() {
t.Fatalf("ModifiedAt is empty")
}
if !c.CreatedAtExported.IsZero() {
t.Fatalf("CreatedAtExported is not empty %d", c.CreatedAtExported.Unix())
}
if !c.ModifiedAtExported.IsZero() {
t.Fatalf("ModifiedAtExported is not empty")
}
testBaseEntityCreateNewId(t, c)
})
t.Run("AddTimeStamps", func(t *testing.T) {
now := time.Now()
Expand Down

0 comments on commit 819199a

Please sign in to comment.