SDK v3 #8
@ -2,79 +2,26 @@ package error
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestEntityAlreadyExists_Error(t *testing.T) {
|
||||
func TestDatabase_Error(t *testing.T) {
|
||||
type fields struct {
|
||||
Reason string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
fields fields
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "Test : Valid error String",
|
||||
want: "EntityAlreadyExists error",
|
||||
name: "Test 1: Reason",
|
||||
fields: fields{Reason: "TEST ERROR"},
|
||||
want: "Database error: TEST 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{}
|
||||
e := Database{
|
||||
Reason: tt.fields.Reason,
|
||||
}
|
||||
if got := e.Error(); got != tt.want {
|
||||
t.Errorf("Error() = %v, want %v", got, tt.want)
|
||||
}
|
||||
|
@ -3,42 +3,9 @@ package models
|
||||
import "testing"
|
||||
|
||||
func TestPostReference_TableName(t *testing.T) {
|
||||
type fields struct {
|
||||
PostID string
|
||||
SourceID string
|
||||
URL string
|
||||
SourcePostID string
|
||||
FullFileURL string
|
||||
PreviewFileURL string
|
||||
SampleFileURL string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
fields fields
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "Test 1: PostReference",
|
||||
fields: fields{},
|
||||
want: "PostReference",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
po := PostReference{
|
||||
PostID: tt.fields.PostID,
|
||||
SourceID: tt.fields.SourceID,
|
||||
URL: tt.fields.URL,
|
||||
PostReferenceConfig: PostReferenceConfig{
|
||||
SourcePostID: tt.fields.SourcePostID,
|
||||
FullFileURL: tt.fields.FullFileURL,
|
||||
PreviewFileURL: tt.fields.PreviewFileURL,
|
||||
SampleFileURL: tt.fields.SampleFileURL,
|
||||
},
|
||||
}
|
||||
if got := po.TableName(); got != tt.want {
|
||||
t.Errorf("TableName() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
postReference := PostReference{}
|
||||
expectedTableName := "PostReference"
|
||||
if tableName := postReference.TableName(); tableName != expectedTableName {
|
||||
t.Fatalf("expected %s, but got %s", expectedTableName, tableName)
|
||||
}
|
||||
}
|
||||
|
@ -3,36 +3,9 @@ package models
|
||||
import "testing"
|
||||
|
||||
func TestPost_TableName(t *testing.T) {
|
||||
type fields struct {
|
||||
BaseModel BaseModel[PostID]
|
||||
Rating Rating
|
||||
Tags []Tag
|
||||
Favorites []UserFavorite
|
||||
References []PostReference
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
fields fields
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "Test 1: Is name Post",
|
||||
fields: fields{},
|
||||
want: "Post",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
po := Post{
|
||||
BaseModel: tt.fields.BaseModel,
|
||||
Rating: tt.fields.Rating,
|
||||
Tags: tt.fields.Tags,
|
||||
Favorites: tt.fields.Favorites,
|
||||
References: tt.fields.References,
|
||||
}
|
||||
if got := po.TableName(); got != tt.want {
|
||||
t.Errorf("TableName() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
post := Post{}
|
||||
expectedTableName := "Post"
|
||||
if tableName := post.TableName(); tableName != expectedTableName {
|
||||
t.Fatalf("expected %s, but got %s", expectedTableName, tableName)
|
||||
}
|
||||
}
|
||||
|
@ -3,38 +3,9 @@ package models
|
||||
import "testing"
|
||||
|
||||
func TestSource_TableName(t *testing.T) {
|
||||
type fields struct {
|
||||
BaseModel BaseModel[SourceID]
|
||||
DisplayName string
|
||||
Domain string
|
||||
Icon string
|
||||
UserSources []UserSource
|
||||
References []PostReference
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
fields fields
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "Test 1: Is name Source",
|
||||
fields: fields{},
|
||||
want: "Source",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
so := Source{
|
||||
BaseModel: tt.fields.BaseModel,
|
||||
DisplayName: tt.fields.DisplayName,
|
||||
Domain: tt.fields.Domain,
|
||||
Icon: tt.fields.Icon,
|
||||
UserSources: tt.fields.UserSources,
|
||||
References: tt.fields.References,
|
||||
}
|
||||
if got := so.TableName(); got != tt.want {
|
||||
t.Errorf("TableName() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
source := Source{}
|
||||
expectedTableName := "Source"
|
||||
if tableName := source.TableName(); tableName != expectedTableName {
|
||||
t.Fatalf("expected %s, but got %s", expectedTableName, tableName)
|
||||
}
|
||||
}
|
||||
|
@ -3,94 +3,25 @@ package models
|
||||
import "testing"
|
||||
|
||||
func TestTagAlias_TableName(t *testing.T) {
|
||||
type fields struct {
|
||||
Name string
|
||||
TagID string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
fields fields
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "Test 1: Is Name TagAlias",
|
||||
fields: fields{},
|
||||
want: "TagAlias",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
ta := TagAlias{
|
||||
Name: tt.fields.Name,
|
||||
TagID: tt.fields.TagID,
|
||||
}
|
||||
if got := ta.TableName(); got != tt.want {
|
||||
t.Errorf("TableName() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
tagAlias := TagAlias{}
|
||||
expectedTableName := "TagAlias"
|
||||
if tableName := tagAlias.TableName(); tableName != expectedTableName {
|
||||
t.Fatalf("expected %s, but got %s", expectedTableName, tableName)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTagGroup_TableName(t *testing.T) {
|
||||
type fields struct {
|
||||
Name string
|
||||
TagID string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
fields fields
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "Test 1: Is name TagGroup",
|
||||
fields: fields{},
|
||||
want: "TagGroup",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
ta := TagGroup{
|
||||
Name: tt.fields.Name,
|
||||
TagID: tt.fields.TagID,
|
||||
}
|
||||
if got := ta.TableName(); got != tt.want {
|
||||
t.Errorf("TableName() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
tagGroup := TagGroup{}
|
||||
expectedTableName := "TagGroup"
|
||||
if tableName := tagGroup.TableName(); tableName != expectedTableName {
|
||||
t.Fatalf("expected %s, but got %s", expectedTableName, tableName)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTag_TableName(t *testing.T) {
|
||||
type fields struct {
|
||||
Name string
|
||||
Type TagType
|
||||
Aliases []TagAlias
|
||||
Groups []TagGroup
|
||||
Posts []Post
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
fields fields
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "Test 1: Is name Tag",
|
||||
fields: fields{},
|
||||
want: "Tag",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
ta := Tag{
|
||||
Name: tt.fields.Name,
|
||||
Type: tt.fields.Type,
|
||||
Aliases: tt.fields.Aliases,
|
||||
Groups: tt.fields.Groups,
|
||||
Posts: tt.fields.Posts,
|
||||
}
|
||||
if got := ta.TableName(); got != tt.want {
|
||||
t.Errorf("TableName() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
func TestTags_TableName(t *testing.T) {
|
||||
tag := Tag{}
|
||||
expectedTableName := "Tag"
|
||||
if tableName := tag.TableName(); tableName != expectedTableName {
|
||||
t.Fatalf("expected %s, but got %s", expectedTableName, tableName)
|
||||
}
|
||||
}
|
||||
|
@ -1,37 +1,11 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
import "testing"
|
||||
|
||||
func TestUserFavorite_TableName(t *testing.T) {
|
||||
type fields struct {
|
||||
UserID string
|
||||
PostID string
|
||||
CreatedAt time.Time
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
fields fields
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "Test 1: Is name UserFavorite",
|
||||
fields: fields{},
|
||||
want: "UserFavorite",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
us := UserFavorite{
|
||||
UserID: tt.fields.UserID,
|
||||
PostID: tt.fields.PostID,
|
||||
CreatedAt: tt.fields.CreatedAt,
|
||||
}
|
||||
if got := us.TableName(); got != tt.want {
|
||||
t.Errorf("TableName() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
userFavorite := UserFavorite{}
|
||||
expectedTableName := "UserFavorites"
|
||||
if tableName := userFavorite.TableName(); tableName != expectedTableName {
|
||||
t.Fatalf("expected %s, but got %s", expectedTableName, tableName)
|
||||
}
|
||||
}
|
||||
|
@ -3,40 +3,9 @@ package models
|
||||
import "testing"
|
||||
|
||||
func TestUserSource_TableName(t *testing.T) {
|
||||
type fields struct {
|
||||
User User
|
||||
UserID UserID
|
||||
Source Source
|
||||
SourceID SourceID
|
||||
ScrapeTimeInterval string
|
||||
AccountUsername string
|
||||
AccountID string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
fields fields
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "Test 1: Is name UserSource",
|
||||
fields: fields{},
|
||||
want: "UserSource",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
us := UserSource{
|
||||
User: tt.fields.User,
|
||||
UserID: tt.fields.UserID,
|
||||
Source: tt.fields.Source,
|
||||
SourceID: tt.fields.SourceID,
|
||||
ScrapeTimeInterval: tt.fields.ScrapeTimeInterval,
|
||||
AccountUsername: tt.fields.AccountUsername,
|
||||
AccountID: tt.fields.AccountID,
|
||||
}
|
||||
if got := us.TableName(); got != tt.want {
|
||||
t.Errorf("TableName() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
userSource := UserSource{}
|
||||
expectedTableName := "UserSource"
|
||||
if tableName := userSource.TableName(); tableName != expectedTableName {
|
||||
t.Fatalf("expected %s, but got %s", expectedTableName, tableName)
|
||||
}
|
||||
}
|
||||
|
@ -3,32 +3,9 @@ package models
|
||||
import "testing"
|
||||
|
||||
func TestUser_TableName(t *testing.T) {
|
||||
type fields struct {
|
||||
BaseModel BaseModel[UserID]
|
||||
Favorites []UserFavorite
|
||||
Sources []UserSource
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
fields fields
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "Test 1: Is name User",
|
||||
fields: fields{},
|
||||
want: "User",
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
us := User{
|
||||
BaseModel: tt.fields.BaseModel,
|
||||
Favorites: tt.fields.Favorites,
|
||||
Sources: tt.fields.Sources,
|
||||
}
|
||||
if got := us.TableName(); got != tt.want {
|
||||
t.Errorf("TableName() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
user := User{}
|
||||
expectedTableName := "User"
|
||||
if tableName := user.TableName(); tableName != expectedTableName {
|
||||
t.Fatalf("expected %s, but got %s", expectedTableName, tableName)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user