fix(errors): added more tests
Some checks failed
Gitea Build Check / Build (push) Failing after 5m41s
Some checks failed
Gitea Build Check / Build (push) Failing after 5m41s
Signed-off-by: SoXX <soxx@fenpa.ws>
This commit is contained in:
parent
615a6b1a25
commit
a026563835
83
pkg/error/database_test.go
Normal file
83
pkg/error/database_test.go
Normal file
@ -0,0 +1,83 @@
|
||||
package error
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestEntityAlreadyExists_Error(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "Test : Valid error String",
|
||||
want: "EntityAlreadyExists error",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
e := &EntityAlreadyExists{}
|
||||
if got := e.Error(); got != tt.want {
|
||||
t.Errorf("Error() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestNoDataFound_Error(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "Test : Valid error String",
|
||||
want: "NoDataFound error",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
e := &NoDataFound{}
|
||||
if got := e.Error(); got != tt.want {
|
||||
t.Errorf("Error() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestNoDataWritten_Error(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "Test : Valid error String",
|
||||
want: "NoDataWritten error",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
e := &NoDataWritten{}
|
||||
if got := e.Error(); got != tt.want {
|
||||
t.Errorf("Error() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestNoRelationCreated_Error(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "Test : Valid error String",
|
||||
want: "relationship creation error",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
e := &NoRelationCreated{}
|
||||
if got := e.Error(); got != tt.want {
|
||||
t.Errorf("Error() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
30
pkg/error/validation_test.go
Normal file
30
pkg/error/validation_test.go
Normal file
@ -0,0 +1,30 @@
|
||||
package error
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestEntityValidationFailed_Error(t *testing.T) {
|
||||
type fields struct {
|
||||
Reason string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
fields fields
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "Test 1: Reason",
|
||||
fields: fields{Reason: "TEST ERROR"},
|
||||
want: "Entity validation failed: TEST ERROR",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
e := EntityValidationFailed{
|
||||
Reason: tt.fields.Reason,
|
||||
}
|
||||
if got := e.Error(); got != tt.want {
|
||||
t.Errorf("Error() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user