Compare commits
No commits in common. "main" and "v4.1.0" have entirely different histories.
@ -1,4 +1,4 @@
|
|||||||
![Build Check Runner](https://git.anthrove.art/Anthrove/otter-space-sdk/v5/actions/workflows/build_check.yaml/badge.svg)
|
![Build Check Runner](https://git.anthrove.art/Anthrove/otter-space-sdk/v4/actions/workflows/build_check.yaml/badge.svg)
|
||||||
[![Bugs](https://sonarqube.dragse.de/api/project_badges/measure?project=Anthrove---OtterSpace-SDK&metric=bugs&token=sqb_96012ffdd64ce721d7f9c82bfa77aa27a5c1fd38)](https://sonarqube.dragse.de/dashboard?id=Anthrove---OtterSpace-SDK)
|
[![Bugs](https://sonarqube.dragse.de/api/project_badges/measure?project=Anthrove---OtterSpace-SDK&metric=bugs&token=sqb_96012ffdd64ce721d7f9c82bfa77aa27a5c1fd38)](https://sonarqube.dragse.de/dashboard?id=Anthrove---OtterSpace-SDK)
|
||||||
[![Code Smells](https://sonarqube.dragse.de/api/project_badges/measure?project=Anthrove---OtterSpace-SDK&metric=code_smells&token=sqb_96012ffdd64ce721d7f9c82bfa77aa27a5c1fd38)](https://sonarqube.dragse.de/dashboard?id=Anthrove---OtterSpace-SDK)
|
[![Code Smells](https://sonarqube.dragse.de/api/project_badges/measure?project=Anthrove---OtterSpace-SDK&metric=code_smells&token=sqb_96012ffdd64ce721d7f9c82bfa77aa27a5c1fd38)](https://sonarqube.dragse.de/dashboard?id=Anthrove---OtterSpace-SDK)
|
||||||
[![Coverage](https://sonarqube.dragse.de/api/project_badges/measure?project=Anthrove---OtterSpace-SDK&metric=coverage&token=sqb_96012ffdd64ce721d7f9c82bfa77aa27a5c1fd38)](https://sonarqube.dragse.de/dashboard?id=Anthrove---OtterSpace-SDK)
|
[![Coverage](https://sonarqube.dragse.de/api/project_badges/measure?project=Anthrove---OtterSpace-SDK&metric=coverage&token=sqb_96012ffdd64ce721d7f9c82bfa77aa27a5c1fd38)](https://sonarqube.dragse.de/dashboard?id=Anthrove---OtterSpace-SDK)
|
||||||
@ -22,7 +22,7 @@ The OtterSpace SDK is a Go package for interacting with the OtterSpace API. It p
|
|||||||
To install the OtterSpace SDK, you can use `go get`:
|
To install the OtterSpace SDK, you can use `go get`:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
go get git.anthrove.art/Anthrove/otter-space-sdk/v5
|
go get git.anthrove.art/Anthrove/otter-space-sdk/v4
|
||||||
````
|
````
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@ -34,8 +34,8 @@ package main
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/database"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/database"
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/models"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/models"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
2
go.mod
2
go.mod
@ -1,4 +1,4 @@
|
|||||||
module git.anthrove.art/Anthrove/otter-space-sdk/v5
|
module git.anthrove.art/Anthrove/otter-space-sdk/v4
|
||||||
|
|
||||||
go 1.22.0
|
go 1.22.0
|
||||||
|
|
||||||
|
@ -5,9 +5,9 @@ import (
|
|||||||
"embed"
|
"embed"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/internal/utils"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/internal/utils"
|
||||||
otterError "git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/error"
|
otterError "git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/error"
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/models"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/models"
|
||||||
migrate "github.com/rubenv/sql-migrate"
|
migrate "github.com/rubenv/sql-migrate"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"go.opentelemetry.io/contrib/bridges/otellogrus"
|
"go.opentelemetry.io/contrib/bridges/otellogrus"
|
||||||
@ -17,7 +17,7 @@ import (
|
|||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
const tracingName = "git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/database"
|
const tracingName = "git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/database"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
//go:embed migrations/*.sql
|
//go:embed migrations/*.sql
|
||||||
@ -70,11 +70,9 @@ func Connect(ctx context.Context, config models.DatabaseConfig) error {
|
|||||||
return utils.HandleError(ctx, span, localLogger, err)
|
return utils.HandleError(ctx, span, localLogger, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.Migrate {
|
err = migrateDatabase(ctx, sqlDB, config)
|
||||||
err = migrateDatabase(ctx, sqlDB, config)
|
if err != nil {
|
||||||
if err != nil {
|
return utils.HandleError(ctx, span, localLogger, err)
|
||||||
return utils.HandleError(ctx, span, localLogger, err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
client = sqlDB
|
client = sqlDB
|
||||||
|
@ -4,8 +4,8 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/models"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/models"
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/test"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/test"
|
||||||
"go.opentelemetry.io/contrib/bridges/otellogrus"
|
"go.opentelemetry.io/contrib/bridges/otellogrus"
|
||||||
"go.opentelemetry.io/otel"
|
"go.opentelemetry.io/otel"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
@ -4,9 +4,9 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/internal/utils"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/internal/utils"
|
||||||
otterError "git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/error"
|
otterError "git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/error"
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/models"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/models"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"go.opentelemetry.io/otel/attribute"
|
"go.opentelemetry.io/otel/attribute"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
@ -7,8 +7,8 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/models"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/models"
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/test"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/test"
|
||||||
"go.opentelemetry.io/contrib/bridges/otellogrus"
|
"go.opentelemetry.io/contrib/bridges/otellogrus"
|
||||||
"go.opentelemetry.io/otel"
|
"go.opentelemetry.io/otel"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
-- +migrate Up
|
|
||||||
ALTER TABLE "PostReference"
|
|
||||||
ALTER COLUMN post_id TYPE CHAR(25),
|
|
||||||
ALTER COLUMN source_id TYPE CHAR(25);
|
|
||||||
|
|
||||||
ALTER TABLE post_tags
|
|
||||||
ALTER COLUMN post_id TYPE CHAR(25);
|
|
||||||
|
|
||||||
ALTER TABLE "UserFavorites"
|
|
||||||
ALTER COLUMN post_id TYPE CHAR(25);
|
|
||||||
|
|
||||||
ALTER TABLE "UserSource"
|
|
||||||
ALTER COLUMN source_id TYPE CHAR(25);
|
|
@ -1,30 +0,0 @@
|
|||||||
-- +migrate Up
|
|
||||||
CREATE TYPE ReportType AS ENUM (
|
|
||||||
'duplicate',
|
|
||||||
'missing_data',
|
|
||||||
'rating_abuse',
|
|
||||||
'illegal_content'
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TYPE ReportState AS ENUM (
|
|
||||||
'pending_unclaimed',
|
|
||||||
'pending',
|
|
||||||
'approved',
|
|
||||||
'partial',
|
|
||||||
'rejected'
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE TABLE "PostReport"
|
|
||||||
(
|
|
||||||
id CHAR(25) NOT NULL PRIMARY KEY,
|
|
||||||
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
deleted_at TIMESTAMP WITH TIME ZONE NULL,
|
|
||||||
post_id CHAR(25) NOT NULL REFERENCES "Post" (id),
|
|
||||||
report_by TEXT NOT NULL REFERENCES "User" (id),
|
|
||||||
report_description TEXT NOT NULL,
|
|
||||||
audit_by TEXT NULL REFERENCES "User" (id),
|
|
||||||
audit_description TEXT NOT NULL,
|
|
||||||
report_type ReportType NOT NULL,
|
|
||||||
report_state ReportState NOT NULL
|
|
||||||
);
|
|
@ -4,9 +4,9 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/internal/utils"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/internal/utils"
|
||||||
otterError "git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/error"
|
otterError "git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/error"
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/models"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/models"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"go.opentelemetry.io/otel/attribute"
|
"go.opentelemetry.io/otel/attribute"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
@ -4,9 +4,9 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/internal/utils"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/internal/utils"
|
||||||
otterError "git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/error"
|
otterError "git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/error"
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/models"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/models"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"go.opentelemetry.io/otel/attribute"
|
"go.opentelemetry.io/otel/attribute"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
@ -6,8 +6,8 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/models"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/models"
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/test"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/test"
|
||||||
"go.opentelemetry.io/contrib/bridges/otellogrus"
|
"go.opentelemetry.io/contrib/bridges/otellogrus"
|
||||||
"go.opentelemetry.io/otel"
|
"go.opentelemetry.io/otel"
|
||||||
)
|
)
|
||||||
|
@ -4,9 +4,9 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/internal/utils"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/internal/utils"
|
||||||
otterError "git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/error"
|
otterError "git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/error"
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/models"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/models"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"go.opentelemetry.io/otel/attribute"
|
"go.opentelemetry.io/otel/attribute"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
@ -6,8 +6,8 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/models"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/models"
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/test"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/test"
|
||||||
"go.opentelemetry.io/contrib/bridges/otellogrus"
|
"go.opentelemetry.io/contrib/bridges/otellogrus"
|
||||||
"go.opentelemetry.io/otel"
|
"go.opentelemetry.io/otel"
|
||||||
)
|
)
|
||||||
|
@ -7,8 +7,8 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/models"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/models"
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/test"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/test"
|
||||||
"go.opentelemetry.io/contrib/bridges/otellogrus"
|
"go.opentelemetry.io/contrib/bridges/otellogrus"
|
||||||
"go.opentelemetry.io/otel"
|
"go.opentelemetry.io/otel"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
@ -4,9 +4,9 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/internal/utils"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/internal/utils"
|
||||||
otterError "git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/error"
|
otterError "git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/error"
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/models"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/models"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"go.opentelemetry.io/otel/attribute"
|
"go.opentelemetry.io/otel/attribute"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
@ -1,173 +0,0 @@
|
|||||||
package database
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"errors"
|
|
||||||
|
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/internal/utils"
|
|
||||||
otterError "git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/error"
|
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/models"
|
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"go.opentelemetry.io/otel/attribute"
|
|
||||||
"gorm.io/gorm"
|
|
||||||
)
|
|
||||||
|
|
||||||
func CreatePostReport(ctx context.Context, postReport models.PostReport) (models.PostReport, error) {
|
|
||||||
ctx, span, localLogger := utils.SetupTracing(ctx, tracer, "CreatePostReport")
|
|
||||||
defer span.End()
|
|
||||||
|
|
||||||
localLogger = localLogger.WithFields(log.Fields{
|
|
||||||
"post_report_id": postReport.ID,
|
|
||||||
})
|
|
||||||
|
|
||||||
span.SetAttributes(
|
|
||||||
attribute.String("post_report_id", string(postReport.ID)),
|
|
||||||
)
|
|
||||||
|
|
||||||
utils.HandleEvent(span, localLogger, "Starting postReport creation")
|
|
||||||
|
|
||||||
if client == nil {
|
|
||||||
return models.PostReport{}, utils.HandleError(ctx, span, localLogger, &otterError.Database{Reason: otterError.DatabaseIsNotConnected})
|
|
||||||
}
|
|
||||||
|
|
||||||
result := client.WithContext(ctx).Create(&postReport)
|
|
||||||
if result.Error != nil {
|
|
||||||
if errors.Is(result.Error, gorm.ErrDuplicatedKey) {
|
|
||||||
return models.PostReport{}, utils.HandleError(ctx, span, localLogger, &otterError.Database{Reason: otterError.DuplicateKey})
|
|
||||||
}
|
|
||||||
return models.PostReport{}, utils.HandleError(ctx, span, localLogger, result.Error)
|
|
||||||
}
|
|
||||||
|
|
||||||
utils.HandleEvent(span, localLogger, "Post createdReport successfully")
|
|
||||||
return postReport, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetPostReportByID(ctx context.Context, id models.PostReportID) (models.PostReport, error) {
|
|
||||||
ctx, span, localLogger := utils.SetupTracing(ctx, tracer, "GetPostReportByID")
|
|
||||||
defer span.End()
|
|
||||||
|
|
||||||
localLogger = localLogger.WithFields(log.Fields{
|
|
||||||
"post_report_id": id,
|
|
||||||
})
|
|
||||||
|
|
||||||
span.SetAttributes(
|
|
||||||
attribute.String("post_report_id", string(id)),
|
|
||||||
)
|
|
||||||
|
|
||||||
utils.HandleEvent(span, localLogger, "Starting get postReport by ID")
|
|
||||||
|
|
||||||
var postReport models.PostReport
|
|
||||||
|
|
||||||
if client == nil {
|
|
||||||
return models.PostReport{}, utils.HandleError(ctx, span, localLogger, &otterError.Database{Reason: otterError.DatabaseIsNotConnected})
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(id) == 0 {
|
|
||||||
return models.PostReport{}, utils.HandleError(ctx, span, localLogger, &otterError.EntityValidationFailed{Reason: otterError.PostReportIDIsEmpty})
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(id) != 25 {
|
|
||||||
return models.PostReport{}, utils.HandleError(ctx, span, localLogger, &otterError.EntityValidationFailed{Reason: otterError.PostReportIDIsWrongLength})
|
|
||||||
}
|
|
||||||
|
|
||||||
result := client.WithContext(ctx).First(&postReport, "id = ?", id)
|
|
||||||
if result.Error != nil {
|
|
||||||
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
|
||||||
return models.PostReport{}, utils.HandleError(ctx, span, localLogger, &otterError.Database{Reason: otterError.NoDataFound})
|
|
||||||
}
|
|
||||||
return models.PostReport{}, utils.HandleError(ctx, span, localLogger, result.Error)
|
|
||||||
}
|
|
||||||
|
|
||||||
utils.HandleEvent(span, localLogger, "PostReport retrieved successfully")
|
|
||||||
return postReport, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// UpdatePostReport updates the PostReport information in the database.
|
|
||||||
// Only a few parameter can be updated:
|
|
||||||
// - AuditBy
|
|
||||||
// - AuditDescription
|
|
||||||
// - ReportType
|
|
||||||
// - ReportState
|
|
||||||
func UpdatePostReport(ctx context.Context, postReport models.PostReport) error {
|
|
||||||
ctx, span, localLogger := utils.SetupTracing(ctx, tracer, "UpdatePostReport")
|
|
||||||
defer span.End()
|
|
||||||
|
|
||||||
localLogger = localLogger.WithFields(log.Fields{
|
|
||||||
"post_report_id": postReport.ID,
|
|
||||||
})
|
|
||||||
|
|
||||||
span.SetAttributes(
|
|
||||||
attribute.String("post_report_id", string(postReport.ID)),
|
|
||||||
)
|
|
||||||
|
|
||||||
utils.HandleEvent(span, localLogger, "Starting postReport update")
|
|
||||||
|
|
||||||
if client == nil {
|
|
||||||
return utils.HandleError(ctx, span, localLogger, &otterError.Database{Reason: otterError.DatabaseIsNotConnected})
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(postReport.ID) == 0 {
|
|
||||||
return utils.HandleError(ctx, span, localLogger, &otterError.EntityValidationFailed{Reason: otterError.PostIDIsEmpty})
|
|
||||||
}
|
|
||||||
|
|
||||||
updatePost := models.PostReport{
|
|
||||||
BaseModel: models.BaseModel[models.PostReportID]{
|
|
||||||
ID: postReport.ID,
|
|
||||||
},
|
|
||||||
AuditBy: postReport.AuditBy,
|
|
||||||
AuditDescription: postReport.AuditDescription,
|
|
||||||
ReportType: postReport.ReportType,
|
|
||||||
ReportState: postReport.ReportState,
|
|
||||||
}
|
|
||||||
|
|
||||||
result := client.WithContext(ctx).Model(&updatePost).Updates(updatePost)
|
|
||||||
if result.Error != nil {
|
|
||||||
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
|
||||||
return utils.HandleError(ctx, span, localLogger, &otterError.Database{Reason: otterError.NoDataFound})
|
|
||||||
}
|
|
||||||
return utils.HandleError(ctx, span, localLogger, result.Error)
|
|
||||||
}
|
|
||||||
|
|
||||||
utils.HandleEvent(span, localLogger, "PostReport updated successfully")
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func DeletePostReport(ctx context.Context, id models.PostReportID) error {
|
|
||||||
ctx, span, localLogger := utils.SetupTracing(ctx, tracer, "DeletePostReport")
|
|
||||||
defer span.End()
|
|
||||||
|
|
||||||
localLogger = localLogger.WithFields(log.Fields{
|
|
||||||
"post_report_id": id,
|
|
||||||
})
|
|
||||||
|
|
||||||
span.SetAttributes(
|
|
||||||
attribute.String("post_report_id", string(id)),
|
|
||||||
)
|
|
||||||
|
|
||||||
utils.HandleEvent(span, localLogger, "Starting delete postReport")
|
|
||||||
|
|
||||||
var postReport models.PostReport
|
|
||||||
|
|
||||||
if client == nil {
|
|
||||||
return utils.HandleError(ctx, span, localLogger, &otterError.Database{Reason: otterError.DatabaseIsNotConnected})
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(id) == 0 {
|
|
||||||
return utils.HandleError(ctx, span, localLogger, &otterError.EntityValidationFailed{Reason: otterError.PostReportIDIsEmpty})
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(id) != 25 {
|
|
||||||
return utils.HandleError(ctx, span, localLogger, &otterError.EntityValidationFailed{Reason: otterError.PostReportIDIsWrongLength})
|
|
||||||
}
|
|
||||||
|
|
||||||
result := client.WithContext(ctx).Delete(&postReport, "id = ?", id)
|
|
||||||
if result.Error != nil {
|
|
||||||
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
|
||||||
return utils.HandleError(ctx, span, localLogger, &otterError.Database{Reason: otterError.NoDataFound})
|
|
||||||
}
|
|
||||||
return utils.HandleError(ctx, span, localLogger, result.Error)
|
|
||||||
}
|
|
||||||
|
|
||||||
utils.HandleEvent(span, localLogger, "PostReport deleted successfully")
|
|
||||||
return nil
|
|
||||||
}
|
|
@ -1,507 +0,0 @@
|
|||||||
package database
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
"reflect"
|
|
||||||
"testing"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/models"
|
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/test"
|
|
||||||
"go.opentelemetry.io/contrib/bridges/otellogrus"
|
|
||||||
"go.opentelemetry.io/otel"
|
|
||||||
"gorm.io/gorm"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestCreatePostReport(t *testing.T) {
|
|
||||||
// Setup trow away container
|
|
||||||
ctx := context.Background()
|
|
||||||
container, gormDB, err := test.StartPostgresContainer(ctx)
|
|
||||||
if err != nil {
|
|
||||||
logger.Fatalf("Could not start PostgreSQL container: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
client = gormDB
|
|
||||||
|
|
||||||
// Setup open telemetry
|
|
||||||
tracer = otel.Tracer(tracingName)
|
|
||||||
|
|
||||||
hook := otellogrus.NewHook(tracingName)
|
|
||||||
logger.AddHook(hook)
|
|
||||||
|
|
||||||
defer container.Terminate(ctx)
|
|
||||||
|
|
||||||
// -- -- Setup Tests
|
|
||||||
|
|
||||||
// -- Create Post to test with
|
|
||||||
validPost := models.Post{
|
|
||||||
BaseModel: models.BaseModel[models.PostID]{
|
|
||||||
ID: models.PostID(fmt.Sprintf("%025s", "Post1")),
|
|
||||||
CreatedAt: time.Now(),
|
|
||||||
UpdatedAt: time.Now(),
|
|
||||||
DeletedAt: gorm.DeletedAt{},
|
|
||||||
},
|
|
||||||
Rating: models.SFW,
|
|
||||||
}
|
|
||||||
|
|
||||||
validPost, err = CreatePost(ctx, validPost)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("CreatePostReport err: %v", err)
|
|
||||||
}
|
|
||||||
// Setup Tests
|
|
||||||
validUser01 := models.User{BaseModel: models.BaseModel[models.UserID]{ID: models.UserID(fmt.Sprintf("%025s", "User1"))}}
|
|
||||||
validUser01, err = CreateUser(ctx, validUser01)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("CreatePostReport err: %v", err)
|
|
||||||
}
|
|
||||||
validUser02 := models.User{BaseModel: models.BaseModel[models.UserID]{ID: models.UserID(fmt.Sprintf("%025s", "User2"))}}
|
|
||||||
validUser02, err = CreateUser(ctx, validUser02)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("CreatePostReport err: %v", err)
|
|
||||||
}
|
|
||||||
// -- Create PostReport to test with
|
|
||||||
validPostReport := models.PostReport{
|
|
||||||
BaseModel: models.BaseModel[models.PostReportID]{
|
|
||||||
ID: models.PostReportID(fmt.Sprintf("%025s", "PostReport1")),
|
|
||||||
CreatedAt: time.Now(),
|
|
||||||
UpdatedAt: time.Now(),
|
|
||||||
DeletedAt: gorm.DeletedAt{},
|
|
||||||
},
|
|
||||||
PostID: validPost.ID,
|
|
||||||
ReportBy: validUser01.ID,
|
|
||||||
ReportDescription: "aaa",
|
|
||||||
AuditBy: &validUser02.ID,
|
|
||||||
AuditDescription: "ahaa",
|
|
||||||
ReportType: models.Duplicate,
|
|
||||||
ReportState: models.Rejected,
|
|
||||||
}
|
|
||||||
// --
|
|
||||||
|
|
||||||
// -- -- Tests
|
|
||||||
type args struct {
|
|
||||||
ctx context.Context
|
|
||||||
source models.PostReport
|
|
||||||
}
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
args args
|
|
||||||
want models.PostReport
|
|
||||||
wantErr bool
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
name: "Test 01: Valid PostReport",
|
|
||||||
args: args{
|
|
||||||
ctx: ctx,
|
|
||||||
source: validPostReport,
|
|
||||||
},
|
|
||||||
want: validPostReport,
|
|
||||||
wantErr: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Test 02: Duplicate PostReport",
|
|
||||||
args: args{
|
|
||||||
ctx: ctx,
|
|
||||||
source: validPostReport,
|
|
||||||
},
|
|
||||||
want: models.PostReport{},
|
|
||||||
wantErr: true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
for _, tt := range tests {
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
|
||||||
got, err := CreatePostReport(tt.args.ctx, tt.args.source)
|
|
||||||
if (err != nil) != tt.wantErr {
|
|
||||||
t.Errorf("CreatePostReport() error = %v, wantErr %v", err, tt.wantErr)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if !reflect.DeepEqual(got, tt.want) {
|
|
||||||
t.Errorf("CreatePostReport() got = %v, want %v", got, tt.want)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestUpdatePostReport(t *testing.T) {
|
|
||||||
// Setup trow away container
|
|
||||||
ctx := context.Background()
|
|
||||||
container, gormDB, err := test.StartPostgresContainer(ctx)
|
|
||||||
if err != nil {
|
|
||||||
logger.Fatalf("Could not start PostgreSQL container: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
client = gormDB
|
|
||||||
|
|
||||||
// Setup open telemetry
|
|
||||||
tracer = otel.Tracer(tracingName)
|
|
||||||
|
|
||||||
hook := otellogrus.NewHook(tracingName)
|
|
||||||
logger.AddHook(hook)
|
|
||||||
|
|
||||||
defer container.Terminate(ctx)
|
|
||||||
|
|
||||||
// -- Create Post to test with
|
|
||||||
validPost := models.Post{
|
|
||||||
BaseModel: models.BaseModel[models.PostID]{
|
|
||||||
ID: models.PostID(fmt.Sprintf("%025s", "Post1")),
|
|
||||||
CreatedAt: time.Now(),
|
|
||||||
UpdatedAt: time.Now(),
|
|
||||||
DeletedAt: gorm.DeletedAt{},
|
|
||||||
},
|
|
||||||
Rating: models.SFW,
|
|
||||||
}
|
|
||||||
|
|
||||||
validPost, err = CreatePost(ctx, validPost)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("CreatePostReport err: %v", err)
|
|
||||||
}
|
|
||||||
// Setup Tests
|
|
||||||
validUser01 := models.User{BaseModel: models.BaseModel[models.UserID]{ID: models.UserID(fmt.Sprintf("%025s", "User1"))}}
|
|
||||||
validUser01, err = CreateUser(ctx, validUser01)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("CreatePostReport err: %v", err)
|
|
||||||
}
|
|
||||||
validUser02 := models.User{BaseModel: models.BaseModel[models.UserID]{ID: models.UserID(fmt.Sprintf("%025s", "User2"))}}
|
|
||||||
validUser02, err = CreateUser(ctx, validUser02)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("CreatePostReport err: %v", err)
|
|
||||||
}
|
|
||||||
// -- Create PostReport to test with
|
|
||||||
validPostReport := models.PostReport{
|
|
||||||
BaseModel: models.BaseModel[models.PostReportID]{
|
|
||||||
ID: models.PostReportID(fmt.Sprintf("%025s", "PostReport1")),
|
|
||||||
CreatedAt: time.Now(),
|
|
||||||
UpdatedAt: time.Now(),
|
|
||||||
DeletedAt: gorm.DeletedAt{},
|
|
||||||
},
|
|
||||||
PostID: validPost.ID,
|
|
||||||
ReportBy: validUser01.ID,
|
|
||||||
ReportDescription: "aaa",
|
|
||||||
AuditBy: nil,
|
|
||||||
AuditDescription: "",
|
|
||||||
ReportType: models.Duplicate,
|
|
||||||
ReportState: models.Rejected,
|
|
||||||
}
|
|
||||||
// --
|
|
||||||
|
|
||||||
validPostReport, err = CreatePostReport(ctx, validPostReport)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("CreatePostReport err: %v", err)
|
|
||||||
}
|
|
||||||
// --
|
|
||||||
|
|
||||||
// -- Create Updates models for UserPostReport
|
|
||||||
validUpdatePostReport := validPostReport
|
|
||||||
validUpdatePostReport.AuditBy = &validUser02.ID
|
|
||||||
validUpdatePostReport.AuditDescription = "aaaaa"
|
|
||||||
validUpdatePostReport.ReportState = models.Approved
|
|
||||||
|
|
||||||
invalidUpdatePostReport := models.PostReport{}
|
|
||||||
// --
|
|
||||||
|
|
||||||
// -- -- Tests
|
|
||||||
type args struct {
|
|
||||||
ctx context.Context
|
|
||||||
source models.PostReport
|
|
||||||
}
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
args args
|
|
||||||
wantErr bool
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
name: "Test 01: Valid Update for PostReport",
|
|
||||||
args: args{
|
|
||||||
ctx: ctx,
|
|
||||||
source: validUpdatePostReport,
|
|
||||||
},
|
|
||||||
wantErr: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Test 02: Invalid Update for PostReport",
|
|
||||||
args: args{
|
|
||||||
ctx: ctx,
|
|
||||||
source: invalidUpdatePostReport,
|
|
||||||
},
|
|
||||||
wantErr: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Test 03: Empty ID for Update for PostReport",
|
|
||||||
args: args{
|
|
||||||
ctx: ctx,
|
|
||||||
source: models.PostReport{BaseModel: models.BaseModel[models.PostReportID]{ID: ""}},
|
|
||||||
},
|
|
||||||
wantErr: true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
for _, tt := range tests {
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
|
||||||
if err := UpdatePostReport(tt.args.ctx, tt.args.source); (err != nil) != tt.wantErr {
|
|
||||||
t.Errorf("UpdatePostReport() error = %v, wantErr %v", err, tt.wantErr)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGetPostReportByID(t *testing.T) {
|
|
||||||
// Setup trow away container
|
|
||||||
ctx := context.Background()
|
|
||||||
container, gormDB, err := test.StartPostgresContainer(ctx)
|
|
||||||
if err != nil {
|
|
||||||
logger.Fatalf("Could not start PostgreSQL container: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
client = gormDB
|
|
||||||
|
|
||||||
// Setup open telemetry
|
|
||||||
tracer = otel.Tracer(tracingName)
|
|
||||||
|
|
||||||
hook := otellogrus.NewHook(tracingName)
|
|
||||||
logger.AddHook(hook)
|
|
||||||
|
|
||||||
defer container.Terminate(ctx)
|
|
||||||
|
|
||||||
// -- -- Setup Tests
|
|
||||||
// -- Create Post to test with
|
|
||||||
validPost := models.Post{
|
|
||||||
BaseModel: models.BaseModel[models.PostID]{
|
|
||||||
ID: models.PostID(fmt.Sprintf("%025s", "Post1")),
|
|
||||||
CreatedAt: time.Now(),
|
|
||||||
UpdatedAt: time.Now(),
|
|
||||||
DeletedAt: gorm.DeletedAt{},
|
|
||||||
},
|
|
||||||
Rating: models.SFW,
|
|
||||||
}
|
|
||||||
|
|
||||||
validPost, err = CreatePost(ctx, validPost)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("CreatePostReport err: %v", err)
|
|
||||||
}
|
|
||||||
// Setup Tests
|
|
||||||
validUser01 := models.User{BaseModel: models.BaseModel[models.UserID]{ID: models.UserID(fmt.Sprintf("%025s", "User1"))}}
|
|
||||||
validUser01, err = CreateUser(ctx, validUser01)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("CreatePostReport err: %v", err)
|
|
||||||
}
|
|
||||||
validUser02 := models.User{BaseModel: models.BaseModel[models.UserID]{ID: models.UserID(fmt.Sprintf("%025s", "User2"))}}
|
|
||||||
validUser02, err = CreateUser(ctx, validUser02)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("CreatePostReport err: %v", err)
|
|
||||||
}
|
|
||||||
// -- Create PostReport to test with
|
|
||||||
validPostReport := models.PostReport{
|
|
||||||
BaseModel: models.BaseModel[models.PostReportID]{
|
|
||||||
ID: models.PostReportID(fmt.Sprintf("%025s", "PostReport1")),
|
|
||||||
CreatedAt: time.Now(),
|
|
||||||
UpdatedAt: time.Now(),
|
|
||||||
DeletedAt: gorm.DeletedAt{},
|
|
||||||
},
|
|
||||||
PostID: validPost.ID,
|
|
||||||
ReportBy: validUser01.ID,
|
|
||||||
ReportDescription: "aaa",
|
|
||||||
AuditBy: nil,
|
|
||||||
AuditDescription: "",
|
|
||||||
ReportType: models.Duplicate,
|
|
||||||
ReportState: models.Rejected,
|
|
||||||
}
|
|
||||||
// --
|
|
||||||
|
|
||||||
validPostReport, err = CreatePostReport(ctx, validPostReport)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("CreatePostReport err: %v", err)
|
|
||||||
}
|
|
||||||
// --
|
|
||||||
// --
|
|
||||||
|
|
||||||
// -- -- Tests
|
|
||||||
type args struct {
|
|
||||||
ctx context.Context
|
|
||||||
id models.PostReportID
|
|
||||||
}
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
args args
|
|
||||||
want models.PostReport
|
|
||||||
wantErr bool
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
name: "Test 01: Valid PostReport ID",
|
|
||||||
args: args{
|
|
||||||
ctx: ctx,
|
|
||||||
id: validPostReport.ID,
|
|
||||||
},
|
|
||||||
want: validPostReport,
|
|
||||||
wantErr: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Test 03: Empty PostReportID",
|
|
||||||
args: args{
|
|
||||||
ctx: ctx,
|
|
||||||
id: "",
|
|
||||||
},
|
|
||||||
wantErr: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Test 04: Short PostReportID",
|
|
||||||
args: args{
|
|
||||||
ctx: ctx,
|
|
||||||
id: "111",
|
|
||||||
},
|
|
||||||
wantErr: true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
for _, tt := range tests {
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
|
||||||
got, err := GetPostReportByID(tt.args.ctx, tt.args.id)
|
|
||||||
if (err != nil) != tt.wantErr {
|
|
||||||
t.Errorf("GetPostReportByID() error = %v, wantErr %v", err, tt.wantErr)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if !checkPostReportID(got, tt.want) {
|
|
||||||
t.Errorf("GetPostReportByID() got = %v, want %v", got, tt.want)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestDeletePostReport(t *testing.T) {
|
|
||||||
// Setup trow away container
|
|
||||||
ctx := context.Background()
|
|
||||||
container, gormDB, err := test.StartPostgresContainer(ctx)
|
|
||||||
if err != nil {
|
|
||||||
logger.Fatalf("Could not start PostgreSQL container: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
client = gormDB
|
|
||||||
|
|
||||||
// Setup open telemetry
|
|
||||||
tracer = otel.Tracer(tracingName)
|
|
||||||
|
|
||||||
hook := otellogrus.NewHook(tracingName)
|
|
||||||
logger.AddHook(hook)
|
|
||||||
|
|
||||||
defer container.Terminate(ctx)
|
|
||||||
|
|
||||||
// -- -- Setup Tests
|
|
||||||
// -- Create Post to test with
|
|
||||||
validPost := models.Post{
|
|
||||||
BaseModel: models.BaseModel[models.PostID]{
|
|
||||||
ID: models.PostID(fmt.Sprintf("%025s", "Post1")),
|
|
||||||
CreatedAt: time.Now(),
|
|
||||||
UpdatedAt: time.Now(),
|
|
||||||
DeletedAt: gorm.DeletedAt{},
|
|
||||||
},
|
|
||||||
Rating: models.SFW,
|
|
||||||
}
|
|
||||||
|
|
||||||
validPost, err = CreatePost(ctx, validPost)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("CreatePostReport err: %v", err)
|
|
||||||
}
|
|
||||||
// Setup Tests
|
|
||||||
validUser01 := models.User{BaseModel: models.BaseModel[models.UserID]{ID: models.UserID(fmt.Sprintf("%025s", "User1"))}}
|
|
||||||
validUser01, err = CreateUser(ctx, validUser01)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("CreatePostReport err: %v", err)
|
|
||||||
}
|
|
||||||
validUser02 := models.User{BaseModel: models.BaseModel[models.UserID]{ID: models.UserID(fmt.Sprintf("%025s", "User2"))}}
|
|
||||||
validUser02, err = CreateUser(ctx, validUser02)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("CreatePostReport err: %v", err)
|
|
||||||
}
|
|
||||||
// -- Create PostReport to test with
|
|
||||||
validPostReport := models.PostReport{
|
|
||||||
BaseModel: models.BaseModel[models.PostReportID]{
|
|
||||||
ID: models.PostReportID(fmt.Sprintf("%025s", "PostReport1")),
|
|
||||||
CreatedAt: time.Now(),
|
|
||||||
UpdatedAt: time.Now(),
|
|
||||||
DeletedAt: gorm.DeletedAt{},
|
|
||||||
},
|
|
||||||
PostID: validPost.ID,
|
|
||||||
ReportBy: validUser01.ID,
|
|
||||||
ReportDescription: "aaa",
|
|
||||||
AuditBy: nil,
|
|
||||||
AuditDescription: "",
|
|
||||||
ReportType: models.Duplicate,
|
|
||||||
ReportState: models.Rejected,
|
|
||||||
}
|
|
||||||
// --
|
|
||||||
|
|
||||||
validPostReport, err = CreatePostReport(ctx, validPostReport)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("CreatePostReport err: %v", err)
|
|
||||||
}
|
|
||||||
// --
|
|
||||||
// --
|
|
||||||
|
|
||||||
// -- -- Tests
|
|
||||||
type args struct {
|
|
||||||
ctx context.Context
|
|
||||||
id models.PostReportID
|
|
||||||
}
|
|
||||||
tests := []struct {
|
|
||||||
name string
|
|
||||||
args args
|
|
||||||
wantErr bool
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
name: "Test 01: Delete Valid PostReport",
|
|
||||||
args: args{
|
|
||||||
ctx: ctx,
|
|
||||||
id: validPostReport.ID,
|
|
||||||
},
|
|
||||||
wantErr: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Test 02: Delete not existed PostReport",
|
|
||||||
args: args{
|
|
||||||
ctx: ctx,
|
|
||||||
id: validPostReport.ID,
|
|
||||||
},
|
|
||||||
wantErr: false,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Test 03: Empty PostReportID",
|
|
||||||
args: args{
|
|
||||||
ctx: ctx,
|
|
||||||
id: "",
|
|
||||||
},
|
|
||||||
wantErr: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Test 04: Short PostReportID",
|
|
||||||
args: args{
|
|
||||||
ctx: ctx,
|
|
||||||
id: "111",
|
|
||||||
},
|
|
||||||
wantErr: true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
for _, tt := range tests {
|
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
|
||||||
if err := DeletePostReport(tt.args.ctx, tt.args.id); (err != nil) != tt.wantErr {
|
|
||||||
t.Errorf("DeletePostReport() error = %v, wantErr %v", err, tt.wantErr)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func checkPostReportID(got models.PostReport, want models.PostReport) bool {
|
|
||||||
if got.ID != want.ID {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
@ -7,8 +7,8 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/models"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/models"
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/test"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/test"
|
||||||
"go.opentelemetry.io/contrib/bridges/otellogrus"
|
"go.opentelemetry.io/contrib/bridges/otellogrus"
|
||||||
"go.opentelemetry.io/otel"
|
"go.opentelemetry.io/otel"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
@ -3,7 +3,7 @@ package database
|
|||||||
import (
|
import (
|
||||||
"math"
|
"math"
|
||||||
|
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/models"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/models"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -5,8 +5,8 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/models"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/models"
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/test"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/test"
|
||||||
"go.opentelemetry.io/contrib/bridges/otellogrus"
|
"go.opentelemetry.io/contrib/bridges/otellogrus"
|
||||||
"go.opentelemetry.io/otel"
|
"go.opentelemetry.io/otel"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
@ -4,9 +4,9 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/internal/utils"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/internal/utils"
|
||||||
otterError "git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/error"
|
otterError "git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/error"
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/models"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/models"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"go.opentelemetry.io/otel/attribute"
|
"go.opentelemetry.io/otel/attribute"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
@ -6,8 +6,8 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/models"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/models"
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/test"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/test"
|
||||||
"go.opentelemetry.io/contrib/bridges/otellogrus"
|
"go.opentelemetry.io/contrib/bridges/otellogrus"
|
||||||
"go.opentelemetry.io/otel"
|
"go.opentelemetry.io/otel"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
@ -4,9 +4,9 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/internal/utils"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/internal/utils"
|
||||||
otterError "git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/error"
|
otterError "git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/error"
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/models"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/models"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"go.opentelemetry.io/otel/attribute"
|
"go.opentelemetry.io/otel/attribute"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
@ -7,8 +7,8 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/models"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/models"
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/test"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/test"
|
||||||
"go.opentelemetry.io/contrib/bridges/otellogrus"
|
"go.opentelemetry.io/contrib/bridges/otellogrus"
|
||||||
"go.opentelemetry.io/otel"
|
"go.opentelemetry.io/otel"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
@ -4,9 +4,9 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/internal/utils"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/internal/utils"
|
||||||
otterError "git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/error"
|
otterError "git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/error"
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/models"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/models"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"go.opentelemetry.io/otel/attribute"
|
"go.opentelemetry.io/otel/attribute"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
@ -4,9 +4,9 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/internal/utils"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/internal/utils"
|
||||||
otterError "git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/error"
|
otterError "git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/error"
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/models"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/models"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"go.opentelemetry.io/otel/attribute"
|
"go.opentelemetry.io/otel/attribute"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
@ -5,8 +5,8 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/models"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/models"
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/test"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/test"
|
||||||
"go.opentelemetry.io/contrib/bridges/otellogrus"
|
"go.opentelemetry.io/contrib/bridges/otellogrus"
|
||||||
"go.opentelemetry.io/otel"
|
"go.opentelemetry.io/otel"
|
||||||
)
|
)
|
||||||
|
@ -4,9 +4,9 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/internal/utils"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/internal/utils"
|
||||||
otterError "git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/error"
|
otterError "git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/error"
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/models"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/models"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"go.opentelemetry.io/otel/attribute"
|
"go.opentelemetry.io/otel/attribute"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
@ -5,8 +5,8 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/models"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/models"
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/test"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/test"
|
||||||
"go.opentelemetry.io/contrib/bridges/otellogrus"
|
"go.opentelemetry.io/contrib/bridges/otellogrus"
|
||||||
"go.opentelemetry.io/otel"
|
"go.opentelemetry.io/otel"
|
||||||
)
|
)
|
||||||
|
@ -5,8 +5,8 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/models"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/models"
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/test"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/test"
|
||||||
"go.opentelemetry.io/contrib/bridges/otellogrus"
|
"go.opentelemetry.io/contrib/bridges/otellogrus"
|
||||||
"go.opentelemetry.io/otel"
|
"go.opentelemetry.io/otel"
|
||||||
)
|
)
|
||||||
|
@ -4,9 +4,9 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/internal/utils"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/internal/utils"
|
||||||
otterError "git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/error"
|
otterError "git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/error"
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/models"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/models"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"go.opentelemetry.io/otel/attribute"
|
"go.opentelemetry.io/otel/attribute"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
@ -4,9 +4,9 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/internal/utils"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/internal/utils"
|
||||||
otterError "git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/error"
|
otterError "git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/error"
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/models"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/models"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"go.opentelemetry.io/otel/attribute"
|
"go.opentelemetry.io/otel/attribute"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
@ -7,8 +7,8 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/models"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/models"
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/test"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/test"
|
||||||
"go.opentelemetry.io/contrib/bridges/otellogrus"
|
"go.opentelemetry.io/contrib/bridges/otellogrus"
|
||||||
"go.opentelemetry.io/otel"
|
"go.opentelemetry.io/otel"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
@ -5,8 +5,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/models"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/models"
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/test"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/test"
|
||||||
"go.opentelemetry.io/contrib/bridges/otellogrus"
|
"go.opentelemetry.io/contrib/bridges/otellogrus"
|
||||||
"go.opentelemetry.io/otel"
|
"go.opentelemetry.io/otel"
|
||||||
)
|
)
|
||||||
|
@ -26,7 +26,7 @@ const (
|
|||||||
UserFavoriteIsWrongLength = "userFavoriteID has the wrong length"
|
UserFavoriteIsWrongLength = "userFavoriteID has the wrong length"
|
||||||
|
|
||||||
PostListIsEmpty = "userFavoriteList cannot be empty"
|
PostListIsEmpty = "userFavoriteList cannot be empty"
|
||||||
PostIDIsEmpty = "PostID cannot be empty"
|
PostIDIsEmpty = "userFavoriteID cannot be empty"
|
||||||
PostIDIsWrongLength = "PostID has the wrong length"
|
PostIDIsWrongLength = "PostID has the wrong length"
|
||||||
|
|
||||||
BatchSizeIsEmpty = "batchSize cannot be empty"
|
BatchSizeIsEmpty = "batchSize cannot be empty"
|
||||||
@ -38,9 +38,6 @@ const (
|
|||||||
|
|
||||||
ScrapeTaskIDIsEmpty = "ScrapeTaskID cannot be empty"
|
ScrapeTaskIDIsEmpty = "ScrapeTaskID cannot be empty"
|
||||||
ScrapeTaskIDIsWrongLength = "ScrapeTaskID has the wrong length, needs to be 25 characters long"
|
ScrapeTaskIDIsWrongLength = "ScrapeTaskID has the wrong length, needs to be 25 characters long"
|
||||||
|
|
||||||
PostReportIDIsEmpty = "PostReportID cannot be empty"
|
|
||||||
PostReportIDIsWrongLength = "PostReportID has the wrong length"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type EntityValidationFailed struct {
|
type EntityValidationFailed struct {
|
||||||
|
@ -9,5 +9,4 @@ type DatabaseConfig struct {
|
|||||||
SSL bool `env:"DB_SSL,required" envDefault:"true"`
|
SSL bool `env:"DB_SSL,required" envDefault:"true"`
|
||||||
Timezone string `env:"DB_TIMEZONE,required" envDefault:"Europe/Berlin"`
|
Timezone string `env:"DB_TIMEZONE,required" envDefault:"Europe/Berlin"`
|
||||||
Debug bool `env:"DB_DEBUG" envDefault:"false"`
|
Debug bool `env:"DB_DEBUG" envDefault:"false"`
|
||||||
Migrate bool
|
|
||||||
}
|
}
|
||||||
|
@ -25,10 +25,6 @@ type (
|
|||||||
UserFavoriteID string
|
UserFavoriteID string
|
||||||
|
|
||||||
ScrapeTaskID string
|
ScrapeTaskID string
|
||||||
|
|
||||||
PostReportID string
|
|
||||||
ReportType string
|
|
||||||
ReportState string
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -54,21 +50,6 @@ const (
|
|||||||
Copyright TagType = "copyright"
|
Copyright TagType = "copyright"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
Duplicate ReportType = "duplicate"
|
|
||||||
MissingData ReportType = "missing_data"
|
|
||||||
RatingAbuse ReportType = "rating_abuse"
|
|
||||||
IllegalContent ReportType = "illegal_content"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
PendingUnclaimed ReportState = "pending_unclaimed"
|
|
||||||
Pending ReportState = "pending"
|
|
||||||
Approved ReportState = "approved"
|
|
||||||
Partial ReportState = "partial"
|
|
||||||
Rejected ReportState = "rejected"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (r *Rating) Convert(e621Rating string) {
|
func (r *Rating) Convert(e621Rating string) {
|
||||||
switch e621Rating {
|
switch e621Rating {
|
||||||
case "e":
|
case "e":
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type ID interface {
|
type ID interface {
|
||||||
UserID | SourceID | PostID | UserSourceID | UserFavoriteID | PoolID | PostReportID
|
UserID | SourceID | PostID | UserSourceID | UserFavoriteID | PoolID
|
||||||
}
|
}
|
||||||
|
|
||||||
type BaseModel[T ID] struct {
|
type BaseModel[T ID] struct {
|
||||||
|
@ -9,10 +9,8 @@ const (
|
|||||||
|
|
||||||
type Pool struct {
|
type Pool struct {
|
||||||
BaseModel[PoolID]
|
BaseModel[PoolID]
|
||||||
Name string `json:"name" gorm:"column:name;type:varchar(25)"`
|
Name string `json:"name" gorm:"type:varchar(25)"`
|
||||||
Category PoolCategory `json:"category" gorm:"column:category;type:pool_category;type:enum('series', 'collection')"`
|
Category PoolCategory `json:"category" gorm:"type:pool_category;type:enum('series', 'collection')"`
|
||||||
Posts []PoolPost `json:"posts" gorm:"foreignKey:PoolID"`
|
|
||||||
Sources []PoolReference `json:"sources" gorm:"foreignKey:PoolID"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (Pool) TableName() string {
|
func (Pool) TableName() string {
|
||||||
@ -20,10 +18,11 @@ func (Pool) TableName() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type PoolPost struct {
|
type PoolPost struct {
|
||||||
PoolID PoolID `json:"pool_id" gorm:"column:pool_id;primaryKey"`
|
Pool Pool `json:"pool" gorm:"foreignKey:ID;references:PoolID"`
|
||||||
Pool Pool `json:"-"`
|
PoolID PoolID `json:"pool_id" gorm:""`
|
||||||
PostID PostID `json:"post_id" gorm:"column:post_id;primaryKey"`
|
Post Post `json:"post" gorm:"foreignKey:ID;references:PostID"`
|
||||||
OrderPosition int `json:"order_position" gorm:"column:order_position;default:0"`
|
PostID PostID `json:"post_id" gorm:""`
|
||||||
|
OrderPosition int `json:"order_position" gorm:"not null;default:0"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (PoolPost) TableName() string {
|
func (PoolPost) TableName() string {
|
||||||
@ -31,10 +30,11 @@ func (PoolPost) TableName() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type PoolReference struct {
|
type PoolReference struct {
|
||||||
PoolID PoolID `json:"pool_id" gorm:"column:pool_id;primaryKey"`
|
Pool Pool `json:"pool" gorm:"foreignKey:ID;references:PoolID"`
|
||||||
Pool Pool `json:"-"`
|
PoolID PoolID `json:"pool_id" gorm:""`
|
||||||
SourceID SourceID `json:"source_id" gorm:"column:source_id;primaryKey"`
|
Source Source `json:"source" gorm:"foreignKey:ID;references:SourceID"`
|
||||||
URL string `json:"url" gorm:"column:url;primaryKey"`
|
SourceID SourceID `json:"source_id" gorm:""`
|
||||||
|
URL string `json:"url" gorm:"not null"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (PoolReference) TableName() string {
|
func (PoolReference) TableName() string {
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
package models
|
|
||||||
|
|
||||||
type PostReport struct {
|
|
||||||
BaseModel[PostReportID]
|
|
||||||
PostID PostID `json:"post_id"`
|
|
||||||
ReportBy UserID `json:"report_by"`
|
|
||||||
ReportDescription string `json:"report_description"`
|
|
||||||
AuditBy *UserID `json:"audit_by"`
|
|
||||||
AuditDescription string `json:"audit_description"`
|
|
||||||
ReportType ReportType `json:"report_type" gorm:"type:enum('duplicate','missing_data','rating_abuse','illegal_content')"`
|
|
||||||
ReportState ReportState `json:"report_state" gorm:"type:enum('pending_unclaimed', 'pending', 'approved', 'partial', 'rejected')"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (PostReport) TableName() string {
|
|
||||||
return "PostReport"
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
package models
|
|
||||||
|
|
||||||
import "testing"
|
|
||||||
|
|
||||||
func TestPostReport_TableName(t *testing.T) {
|
|
||||||
postReport := PostReport{}
|
|
||||||
expectedTableName := "PostReport"
|
|
||||||
if tableName := postReport.TableName(); tableName != expectedTableName {
|
|
||||||
t.Fatalf("expected %s, but got %s", expectedTableName, tableName)
|
|
||||||
}
|
|
||||||
}
|
|
@ -5,7 +5,7 @@ import (
|
|||||||
"math/rand"
|
"math/rand"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/models"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/models"
|
||||||
"github.com/davecgh/go-spew/spew"
|
"github.com/davecgh/go-spew/spew"
|
||||||
gonanoid "github.com/matoous/go-nanoid/v2"
|
gonanoid "github.com/matoous/go-nanoid/v2"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.anthrove.art/Anthrove/otter-space-sdk/v5/pkg/models"
|
"git.anthrove.art/Anthrove/otter-space-sdk/v4/pkg/models"
|
||||||
migrate "github.com/rubenv/sql-migrate"
|
migrate "github.com/rubenv/sql-migrate"
|
||||||
postgrescontainer "github.com/testcontainers/testcontainers-go/modules/postgres"
|
postgrescontainer "github.com/testcontainers/testcontainers-go/modules/postgres"
|
||||||
"gorm.io/driver/postgres"
|
"gorm.io/driver/postgres"
|
||||||
@ -121,7 +121,6 @@ func DatabaseModesFromConnectionString(ctx context.Context, pgContainer *postgre
|
|||||||
SSL: false,
|
SSL: false,
|
||||||
Timezone: "Europe/Berlin",
|
Timezone: "Europe/Berlin",
|
||||||
Debug: true,
|
Debug: true,
|
||||||
Migrate: true,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return databaseConfig, nil
|
return databaseConfig, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user