BREAKING CHANGE: V2 of thr SDK #12
@ -159,50 +159,6 @@ func TestGetAllSourceNodes(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetAllSourceWithNoData(t *testing.T) {
|
||||
// Setup trow away container
|
||||
ctx := context.Background()
|
||||
container, gormDB, err := test.StartPostgresContainer(ctx)
|
||||
if err != nil {
|
||||
t.Fatalf("Could not start PostgreSQL container: %v", err)
|
||||
}
|
||||
defer container.Terminate(ctx)
|
||||
|
||||
// Test
|
||||
type args struct {
|
||||
ctx context.Context
|
||||
db *gorm.DB
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want []models.Source
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "Test 1: Get all entries",
|
||||
args: args{
|
||||
ctx: ctx,
|
||||
db: gormDB,
|
||||
},
|
||||
want: nil,
|
||||
wantErr: true,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
got, err := GetAllSource(tt.args.ctx, tt.args.db)
|
||||
if (err != nil) != tt.wantErr {
|
||||
t.Errorf("GetAllSource() error = %v, wantErr %v", err, tt.wantErr)
|
||||
return
|
||||
}
|
||||
if !checkSourcesNode(got, tt.want) {
|
||||
t.Errorf("GetAllSource() got = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetSourceNodesByURL(t *testing.T) {
|
||||
// Setup trow away container
|
||||
ctx := context.Background()
|
||||
|
@ -28,16 +28,13 @@ func CreateUser(ctx context.Context, db *gorm.DB, anthroveUserID models.Anthrove
|
||||
|
||||
result := db.WithContext(ctx).FirstOrCreate(&user)
|
||||
if result.Error != nil {
|
||||
|
||||
if errors.Is(result.Error, gorm.ErrDuplicatedKey) {
|
||||
return &otterError.EntityAlreadyExists{}
|
||||
}
|
||||
return result.Error
|
||||
}
|
||||
|
||||
if result.RowsAffected == 0 {
|
||||
return &otterError.EntityAlreadyExists{}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -707,7 +707,7 @@ func TestGetUserSourceLinks(t *testing.T) {
|
||||
}
|
||||
err = CreateSource(ctx, gormDB, eSource)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
t.Fatal("Create Source e621:", err)
|
||||
}
|
||||
|
||||
faSource := &models.Source{
|
||||
@ -717,7 +717,7 @@ func TestGetUserSourceLinks(t *testing.T) {
|
||||
}
|
||||
err = CreateSource(ctx, gormDB, faSource)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
t.Fatal("Create Source fa:", err)
|
||||
}
|
||||
|
||||
expectedResult := make(map[string]models.UserSource)
|
||||
@ -740,11 +740,11 @@ func TestGetUserSourceLinks(t *testing.T) {
|
||||
|
||||
err = CreateUserWithRelationToSource(ctx, gormDB, validAnthroveUserID, eSource.ID, expectedResult["e621"].UserID, expectedResult["e621"].AccountUsername)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
t.Fatal("CreateUserWithRelationToSource e621:", err)
|
||||
}
|
||||
err = CreateUserWithRelationToSource(ctx, gormDB, validAnthroveUserID, faSource.ID, expectedResult["fa"].UserID, expectedResult["fa"].AccountUsername)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
t.Fatal("CreateUserWithRelationToSource fa:", err)
|
||||
}
|
||||
|
||||
// Test
|
||||
|
Reference in New Issue
Block a user